Install MySQL on RHEL9 or CentOS9

Install MySQL on RHEL9

Are you looking to set up MySQL on your RHEL 9 or CentOS 9 server? Follow these detailed steps to install MySQL on RHEL 9 or CentOS 9.

Table of Contents

Introduction

Whether you’re a seasoned system administrator or a newcomer to database management, this step-by-step guide will walk you through the process of installing MySQL on the latest Red Hat Enterprise Linux (RHEL9 – as of the date of this publication) and CentOS operating systems. MySQL, the open-source relational database management system, is a crucial component for many web applications and server configurations.

Install MySQL on RHEL9: Step-by-Step Instructions

Follow these steps to install MySQL on your RHEL9 or CentOS9 OS.

Step 1: Update your system

Before you begin the installation process, it’s essential to ensure that your system is up-to-date. Run the following command(s) in your terminal:

				
					$ sudo dnf update
				
			

Step 2: Install MySQL Server

Install the MySQL Server package using the package manager. In this case, we’ll use DNF:

				
					$ sudo dnf install mysql-server
				
			

As shown below, there are quite a few dependencies installed along with the mysql-server package.

Install MySQL on RHEL9

Photo by admingeek from Infotechys.com

Step 3: Start and Enable MySQL Service

Option #1:

Start the MySQL service and enable it to start on boot:

				
					$ sudo systemctl start mysqld
$ sudo systemctl enable mysqld
				
			

Option #2:

You can also use the --now flag to execute the two commands above at once.

				
					$ sudo systemctl enable --now mysqld

				
			

Step 4: Secure your MySQL Installation

MySQL comes with a script that helps secure your installation. Run it and follow the on-screen instructions:

				
					$ sudo mysql_secure_installation

				
			

Step 5: Access MySQL

Access the MySQL shell to interact with the database:

				
					$ sudo mysql

				
			

Congratulations! You’ve successfully installed MySQL on your RHEL 9 or CentOS 9 server.

Best Practices

By adhering to these best practices, you’ll ensure a secure, reliable, and optimized MySQL installation on your RHEL 9 or CentOS 9 server.

Best PracticeDescription
Regular BackupsImplement a robust backup strategy to safeguard your data. MySQL provides various tools to automate and manage backups.
User PermissionsGrant minimal necessary permissions to MySQL users. Follow the principle of least privilege to enhance security.
Update and PatchKeep your MySQL installation updated by regularly applying patches and updates. This ensures you benefit from the latest features and security fixes.
Firewall ConfigurationConfigure your firewall to allow traffic on the MySQL port (default is 3306) and restrict access to trusted IP addresses.
Monitoring and OptimizationUse MySQL monitoring tools to keep an eye on performance metrics. Optimize queries and configurations for improved efficiency.

Conclusion

Setting up MySQL on RHEL 9 or CentOS 9 doesn’t have to be a daunting task. With this comprehensive guide, you can confidently install MySQL, follow best practices, and optimize your database for optimal performance. Whether you’re managing a small website or a large-scale application, a well-configured MySQL installation is a key component for your server’s success.

Was this article helpful to you? If so, let us know in the comments.

Related Posts

Install MariaDB on CentOS7
Commands
Install MariaDB on CentOS7

In this step-by-step guide, we will show you how to install mariaDB on CentOS7. MariaDB is a fork of MySQL relational database management systems (RDBMS). Table

Read More »

Leave a Reply

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