Introduction:
MariaDB is a popular and robust open-source relational database management system that is compatible with MySQL. It offers excellent performance, scalability, and security features. In this step-by-step guide, we will walk you through the process of installing MariaDB on Rocky Linux 9, allowing you to set up a powerful database system for your applications.
Step 1: Update System Packages
Before installing any software, it is essential to update the system packages to their latest versions. Open a terminal on your Rocky Linux 9 server and run the following command:
sudo dnf update
This command will update the package repositories and ensure that your server has the most recent package information.
Step 2: Install MariaDB:
Rocky Linux 9 provides MariaDB packages in its default repositories, making the installation process straightforward. Run the following command to install MariaDB:
sudo dnf install mariadb-server
This command will install the MariaDB server and its dependencies.
Step 3: Start and Enable MariaDB:
After the installation is complete, start the MariaDB service using the following command:
sudo systemctl start mariadb
To ensure that MariaDB starts automatically on system boot, enable the service by running:
sudo systemctl enable mariadb
Step 4: Secure MariaDB Installation:
To secure your MariaDB installation, run the following command:
sudo mysql_secure_installation
This command will prompt you to set the root password, remove anonymous users, disallow root login remotely, remove the test database, and reload privilege tables. Follow the on-screen prompts and answer “Y” or “N” to the provided questions based on your requirements.
Step 5: Verify MariaDB Installation:
To verify that MariaDB is installed and running correctly, you can check its status using the following command:
sudo systemctl status mariadb
If MariaDB is active and running, you should see a “active (running)” status.
Step 6: Access MariaDB:
To access the MariaDB command-line interface, use the following command:
sudo mysql -u root -p
Enter the root password you set during the secure installation process. You should now be logged in to the MariaDB shell.
Step 7: Optional: Configure Firewall:
By default, Rocky Linux 9 uses firewalld as its firewall management tool. If the firewall is enabled, you need to allow access to the MariaDB port (3306) to allow remote connections. Run the following command to add the necessary firewall rule:
sudo firewall-cmd --add-service=mysql --permanent sudo firewall-cmd --reload
Conclusion:
Congratulations! You have successfully installed MariaDB on Rocky Linux 9. By following the step-by-step guide, you now have a powerful and secure database management system ready for use. Remember to follow best practices for database administration and security, such as creating separate user accounts, managing database permissions, and regularly backing up your data. MariaDB offers a wide range of features and functionalities that can support your applications and help you build efficient and scalable database solutions.