Skip to main content

How to install MySQL on AlmaLinux 8

In this guide we will show you how to install MySQL on AlmaLinux 8.

Updated over 2 weeks ago

MySQL is one of the most widely used database management systems on the Internet today. This system is used to work with fairly large volumes of information. However, MySQL is ideal for both small and large Internet projects. Reliability, high speed and flexibility are the main qualities of MySQL.

1. Installation guide

1.1. Import GPG key repository

Run the following command to install updated GPG keys on AlmaLinux 8:

rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux

1.2. Updating the system

First of all, make sure your system is updated. Run the following command:

dnf update

1.3. Download MySQL

To download MySQL setup files, you first need to navigate to MySQL community website:

<a href="https://community.time4vps.com/uploads/editor/s0/tmorwenxuago.png" target="_blank" rel="nofollow noopener noreferrer">https://community.time4vps.com/uploads/editor/s0/tmorwenxuago.png</a>

On this page you will see a list of setup packages for different systems. To download packages, copy the gray subtext under the package name.

For AlmaLinux 8 select "Red Hat Enterprise Linux 8 / Oracle Linux 8 (Architecture Independent), RPM Package " :

Then type the following command:

wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rp

1.4. Checking MySQL repository packages

To check if the package was downloaded correctly, run the md5sum command together with the setup package name:

md5sum mysql80-community-release-el8-1.noarch.rpm

The output of this command is a combination of numbers and letters. Compare it with the MD5 value provided in the download link on the MySQL website:

If they match, then the packages were loaded correctly. If not, repeat step 2 and make sure you follow the instructions correctly.

1.5. Add repositories

To add MySQL yum repositories run the rpm command together with the package name you have downloaded previously:

rpm -ivh mysql80-community-release-el7-11.noarch.rpm

1.6. Install MySQL

To install MySQL, run the following command:

yum install mysql-server

The system will ask for confirmation, you will need to press Y several times to confirm.

1.7. Start MySQL

To start MySQL, run the following command:

systemctl start mysqld

1.8. Check MySQL status

To check if MySQL is active, run the following command:

systemctl status mysqld

1.9. Changing temporary password

Now, to change the temporary password, run the following command:

mysql_secure_installation

You will receive the following message:

Click "y" to continue. There are three levels of password validation policy on AlmaLinux 8 for MySQL, so you should select the one you want.

To select it, enter the appropriate number and then the password that meets the requirements of the selected policy.

After that, you can enter "y" for all the following requests.

1.10. Connecting to MySQL server

To connect to MySQL as root, run the following command:

mysql -u root -p

You will asked to enter your root password. Type the password and press enter.

Later, to exit MySQL, enter:

exit

2. Additional configurations

2.1. Create a database

To create a database, connect to MySQL and enter the following command (change "database_name" to the actual database name):

CREATE DATABASE database_name;

2.2. Create a user

To create a user, run this command (change the 'username' and 'password' to the actual credentials you want to use):

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

2.3. Delete a user

To delete a user, run the following command (type your actual username instead of 'username' to remove a specific user):

DROP USER ‘username’@‘localhost’;

2.4. Reset user password

You can reset your root password or any other user password at any time. To do that, connect to MySQL as root and run the following command:

ALTER USER 'your_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';

2.5. Disable or stop the MySQL service

MySQL is loaded at system boot by default, however you can disable it manually at any time:

systemctl disable mysqld

To stop the MySQL service, run the following command:

systemctl stop mysqld
Did this answer your question?