How to Install MySQL on AlmaLinux 10

How to Install MySQL on AlmaLinux

MySQL is one of the world’s most popular and widely used relational database management systems (RDBMS). Developed in 1995 by MySQL AB, the software is now under the auspices of Oracle Corporation. MySQL is known for its efficient data management capabilities, flexibility, and compatibility with various platforms and programming languages. This article will show you how to install MySQL server on AlmaLinux 10.

Prerequisites

  • A server with AlmaLinux 10
  • SSH root access or a regular system user with sudo privileges

Conventions

# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user

The easiest and fastest way to install MySQL server on AlmaLinux 10 is from the repository. Execute the command below.

# dnf install mysql-server

You will see the message like this:

Last metadata expiration check: 2:16:01 ago on Mon Mar 31 21:44:11 2025.
Dependencies resolved.
==============================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================
Installing:
mysql-server x86_64_v2 8.4.2-4.el10 appstream 18 M
Installing dependencies:
checkpolicy x86_64_v2 3.7-1.el10 appstream 353 k
libaio x86_64_v2 0.3.111-20.el10 baseos 23 k
libtirpc x86_64_v2 1.3.5-0.el10 baseos 94 k
mariadb-connector-c-config noarch 3.4.1-1.el10 baseos 8.6 k
mecab x86_64_v2 0.996-8.el10 appstream 360 k
mysql x86_64_v2 8.4.2-4.el10 appstream 2.5 M
mysql-common noarch 8.4.2-4.el10 appstream 79 k
mysql-errmsg noarch 8.4.2-4.el10 appstream 528 k
mysql-selinux noarch 1.0.10-4.el10 appstream 36 k
policycoreutils-python-utils noarch 3.7-2.el10 appstream 52 k
protobuf-lite x86_64_v2 3.19.6-10.el10 appstream 256 k
python3-audit x86_64_v2 4.0-9.el10 appstream 67 k
python3-distro noarch 1.9.0-4.el10 appstream 50 k
python3-libsemanage x86_64_v2 3.7-1.el10 appstream 81 k
python3-policycoreutils noarch 3.7-2.el10 appstream 2.2 M
python3-setools x86_64_v2 4.5.1-3.el10 baseos 741 k
python3-setuptools noarch 69.0.3-5.el10 baseos 1.6 M

Transaction Summary
==============================================================================================================================================================================
Install 18 Packages

Total download size: 27 M
Installed size: 183 M
Is this ok [y/N]:

Press Y to proceed with the installation and wait until it finishes.

After a few moments, the MySQL server will be installed. At this point, we need to start it as it does not automatically start upon installation.

# systemctl start mysqld

It should be started now, we can check it with this command:

# systemctl status mysqld

You will get an output like this:

[root@rh ~]# systemctl status mysqld
● mysqld.service - MySQL 8.4 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled)
Active: active (running) since Tue 2025-04-01 00:03:07 CDT; 13s ago
Invocation: 2c73a87b3caa4c7aa5aa577954df84c2
Process: 3756 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 3778 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Main PID: 3854 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 23175)
Memory: 448.4M (peak: 461.1M)
CPU: 7.356s
CGroup: /system.slice/mysqld.service
└─3854 /usr/libexec/mysqld --basedir=/usr

Apr 01 00:02:55 rh.aroel.net systemd[1]: Starting mysqld.service - MySQL 8.4 database server...
Apr 01 00:02:55 rh.aroel.net mysql-prepare-db-dir[3778]: Initializing MySQL database
Apr 01 00:03:07 rh.aroel.net systemd[1]: Started mysqld.service - MySQL 8.4 database server.

As seen above, “Active: active (running)” means that the MySQL server is running now.

If you see the status again, especially in part “Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled)”. This means MySQL will not automatically start when the server is rebooted. To change this, we can execute this command:

# systemctl enable mysqld

The systemctl has now enabled the MySQL service. It will automatically run each time you reboot your server.

Now, we can try to log in to MySQL shell.

# mysql

After running the command, you will see this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 55
Server version: 8.4.2 Source distribution

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Now, you can start working on the MySQL shell. You can type \q then hit ENTER to exit from the shell.

As seen there, we can log in to MySQL shell without a password as the user root. To secure MySQL, we can execute this command:

# mysql_secure_installation

This script will prompt you with a few questions.

[root@rh ~]# 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:

Hit Y then ENTER.

Then, you will see this message below:

There are three levels of password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:

Enter 2 if you want the strongest password.

Then, the script will ask you to type a new root password. Make sure it’s a strong password with at least 8 numeric, mixed-case, and special characters.

New password: 

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :

Choose Y, then hit ENTER

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) :

Press Y, then ENTER

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) :

Again, press Y then ENTER

Remove test database and access to it? (Press y|Y for Yes, any other key for No) :

Hit Y, then ENTER once more

 - 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) :

Finally, press Y then ENTER for the last time.

Success.

All done!

That’s it all! You have successfully installed MySQL Server on AlmaLinux 10 and secured the installation.

Congratulations! You have followed this article, and now you can install MySQL on AlmaLinux 10.

Of course, you don’t have to install MySQL on AlmaLinux 10 if you use one of our managed hosting services. In this case, you can ask our expert Linux admins to install MySQL on AlmaLinux 10. Our expert administrators are available 24×7 and will take care of your request immediately.

If you liked this article, please share it with your friends or leave a comment below.

Leave a Comment