MySQL is an open-source database engine, suitable for small to large sites.
This article walks you through a basic installation of MySQL on a CentOS 8 server.
You need access to a Linux server, with sudoers or root privileges.
Install the MariaDB server package:
#sudo dnf install mariadb-server ... Complete!
To verify that MariaDB is installed and started on your system, run:
# sudo systemctl status mariadb.service ● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/
In our example, CentOS installed MariaDB 10.3 by default. MariaDB is a MySQL drop-in replacement, with additional features.
You can see that CentOS 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 Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
Now, check the status again:
#sudo systemctl status mariadb.service mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2020-03-20 15:15:55 UTC; 25s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 29427 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 5016) Memory: 79.9M CGroup: /system.slice/mariadb.service └─29427 /usr/libexec/mysqld --basedir=/usr● 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:
[root@drab-eagle-9 ~]# 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!
In this article, you learned how to install MariaDB on CentOS 8. 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.