Install and Configure MySQL on Fedora 31

MariaDB is a MySQL drop-in replacement, with additional features. MySQL is an open-source database engine, suitable for small to large sites.

This article walks you through a basic installation of MariaDB on a Fedora 31 server.

Prerequisites

You need access to a Linux server, with sudoers or root privileges.

Installation

Install MySQL

Install the MariaDB server package:

#sudo dnf install mariadb mariadb-server

Verify installation

To verify that MariaDB is installed and started on your system, run:

#sudo systemctl status mariadb.service

● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

You can see that Fedora neither starts, nor enables mariadb for auto-start on reboot (vendor preset: disabled)

We’ll need to do both.

#sudo systemctl start mariadb.service
#sudo systemctl enable mariadb.service

Now, check the status again:

#sudo systemctl status mariadb.service

● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-12-13 19:23:15 UTC; 6min ago
 Main PID: 32025 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─32025 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─32187 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib6...

You should see Active: active (running) as in the example above.

Enter the mysql shell to ensure that you have access. Then type exit to exit the shell.

#mysql

MariaDB [(none)]> exit
Bye

Now you can reach your MySQL from another remote host by using:

mysql -h host_name -u user -p

Run the Secure Installation Tool (Optional)

Finally, we recommend that you run MariaDB Server’s built-in secure installation tool. This will walk you through several steps intended to close some known vulnerabilities with the default installation, and will prompt you on which changes it should make at every step:

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):

...

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Conclusion

In this article, you learned how to install MariaDB on Fedora 31. Next steps should include configuring your firewall to properly allow only the needed traffic to your MariaDB server instance, and configuring users with the correct permissions for your needs.

Leave a Reply

Your email address will not be published. Required fields are marked *