In this tutorial, we will show you how to install MySQL on AlmaLinux 8. For those of you who didn’t know, MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. The MySQL source code is freely available because it was originally developed by Oracle. MySQL is written in C and C++ and is compatible with all major operating systems. MySQL can be used for a variety of applications but is most commonly found on Web servers.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of MySQL databases on an AlmaLinux 8.
Install MySQL on AlmaLinux 8
Step 1. First, let’s start by ensuring your system is up-to-date.
sudo dnf update sudo dnf install epel-release
Step 2. Installing MySQL on AlmaLinux 8.
Now we run the following command to install MySQL:
sudo dnf install mysql-server mysql
Once successfully installed, start to enable it to start on system start-up using:
sudo systemctl restart mysqld sudo systemctl status mysqld sudo systemctl enable mysqld
By default, MariaDB is not hardened. You can secure MariaDB using the
mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
[[email protected] ~]# mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No: Please set the password for root here. New password: Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done!
To log into MariaDB, use the following command (note that it’s the same command you would use to log into a MariaDB database):
mysql -u root -p
One of the most important things when running MySQL on a production server is to get the most out of its performances. If you are a beginner and you do not know how to tune your MySQL server, you can start with a program called MySQLTuner. It will help you to analyze your server and to tune MySQL for better overall performance.
Congratulations! You have successfully installed MySQL. Thanks for using this tutorial for installing MySQL server on your AlmaLinux 8 system. For additional help or useful information, we recommend you check the official MySQL website.