How to Install MySQL On RHEL 9 / Rocky Linux 9

In this tutorial post, we will explain how to install MySQL database server on RHEL 9 or Rocky Linux 9.

How to Install MySQL On RHEL 9 / Rocky Linux 9

Let’s start with the MySQL installation:

Install MySQL on RHEL 9 / Rocky Linux 9

MySQL version 8 is available from the Appstream repository on RHEL 9 / Rocky 9. Before installing the MySQL database server, update the system with the following command:

sudo dnf update

Now, after updating your system run the following command to install the mysql-server package.

sudo dnf install mysql-server -y

Once installed, run the following command to check the version installed:

mysql --version

How to Start and Enable MySQL Server

Start systemd service with the following command:

sudo systemctl start mysqld.service

Once you have executed the command, you might want to confirm if the service is running as shown.

sudo systemctl status mysqld.service

Enable the database server to start on boot using the following command:

sudo systemctl enable mysqld

Secure MySQL on RHEL 9 / Rocky Linux 9

MySQL comes with the mysql_secure_installation security script from where you can modify the default options of your database server.

sudo mysql_secure_installation

You can configure the details like passwords.

How to Access MySQL Database Server

To log in to the MySQL server, run the following command as sudo user. The -u option specifies the user logging in and -p option prompts for the password.

sudo mysql -u root -p

Provide the MySQL root user’s password and hit ENTER.

Conclusion

In this post, we have walked you through the installation of MySQL server  on RHEL 9 or Rocky Linux 9. Let us know if you have any other easy and better way to install database server on RHEL and Rocky Linux.

Leave a comment

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