
MySQL is an open-source relational database management system (RDBMS) that uses the structured query language (SQL) and known for its reliability, performance, and ease of use. MySQL supports small and large-scale web applications to store data in separate table structures. This guide explains how to install MySQL on a Rocky Linux 9 and secure access to the database server console.
Before you begin:
Deploy a Rocky Linux 9 server instance on Vultr.
Access the server using SSH as a non-root user with sudo privileges.
The latest MySQL database server package is available in the default dnf package manager repositories on Rocky Linux 9. You can install specific MySQL versions using the EPEL (Extra Packages for Enterprise Linux) repository on your server. In the following steps, install the latest MySQL version on your server.
Update the DNF package index on your server.
Install the latest MySQL database server package.
View the installed MySQL version on your server.
Output:
MySQL uses the mysqld system service to run on your Rocky Linux 9 server. Follow the steps below to manage the MySQL system service to start, verify and restart the database server.
Enable the MySQL service to start at boot time.
Output:
Start the MySQL service.
View the MySQL system service status and verify that it's running on your server.
Output:
Run the following command to stop the MySQL service.
Restart the MySQL service to reload the database server.
The MySQL database server runs with insecure default settings such as test databases and low password policies on your server after installation. Secure the MySQL database server by setting up a new root user password, remove insecure defaults, and disable remote access to the root user as described in the following steps.
Run the following command to start the MySQL secure installation script.
VALIDATE PASSWORD component to set up the minimum password requirements on your database server.Restart the MySQL service to apply your configuration changes.
The MySQL client utility command mysql allows you to access your database server console by specifying a user and password. Follow the steps below to access your MySQL database server as the root user and create new database users on your server.
Log in to the MySQL console as the root user.
Enter the root password you set earlier when prompted. Then, verify that your prompt changes to the MySQL shell similar to the following output.
Create a sample database such as example_vultr.
View all databases on your server to verify that the new database is available.
Output:
Create a new database user with a strong password based on your MySQL server password strength policy. For example, vultr_user.
Grant the new user full privileges to the sample database.
Refresh the MySQL privilege tables to apply changes.
View all privileges available to the new MySQL user to verify access to the database.
Output:
Based on the above output, the sample MySQL user vultr_user has full privileges to the sample database example_vultr.
Exit the MySQL shell.
You have installed and configured MySQL on your Rocky Linux 9 server and created sample databases for use with MySQL users. MySQL accepts connection requests on the localhost port 127.0.0.1 on your server, open the MySQL configuration file /etc/mysql/my.cnf to modify the listen address to enable remote MySQL connections to the database server. For more information, visit the MySQL documentation.
0 Comments
Be the first to comment and share your perspective with the community.