Use rpm package to install MySQL under CentOS/RHEL system
MySQL is one of the most popular open source relational database management systems. It supports multiple operating systems and programming languages and has excellent performance. and reliability. CentOS/RHEL Linux is one of the most widely used Linux distributions in the open source community, so they are widely used to run MySQL services. This article will introduce how to use rpm packages to install MySQL on CentOS/RHEL systems.
Step 1: Download the MySQL rpm package
Before starting the installation, you need to visit the MySQL official website and download the latest version of MySQL from the download page. Select the version you need and download the rpm package for that version. Usually you need to download the MySQL client and server rpm packages. In this example, we will use MySQL5.7 version for demonstration.
cd /usr/local/src/
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Steps Two: Install the MySQL rpm package
After the download is completed, you need to use the rpm command as the root user to install the MySQL client and server rpm packages.
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
After the installation is complete, you need to update all installed packages to ensure that our system packages are the latest version , and uses MySQL 5.7 as the default yum repository.
yum update
Step 3: Install MySQL server
Before installing the client, we need to install the MySQL server first. Use the command below to install MySQL server.
yum install mysql-server
After the installation starts, you will be prompted for confirmation and you can press the y key to continue installing the MySQL server. After the MySQL server is installed, you can use the systemctl command to start MySQL.
systemctl start mysqld
At this point, you can use the following command to check whether the MySQL server is running.
systemctl status mysqld
Step 4: Install the MySQL client
After the MySQL server is successfully installed, we can start installing the MySQL client. Run the following command to install the client into your system.
yum install mysql
After executing this command, you will have MySQL installed in your system. Once the installation is complete, you can access the MySQL server using the mysql command in the terminal.
mysql -u root -p
Step 5: Configure MySQL
After installing and running MySQL, we need to set the root password for the server and protect its security. To set the root password, run the following command.
mysql_secure_installation
When running this command, you will be prompted to follow the steps below to set the MySQL root password.
After completing the above steps, the root password will be set and the MySQL server will be secured.
Conclusion
Using the above steps, you can use the rpm package to install MySQL on a CentOS/RHEL system and perform basic configuration and protection. It's a quick and easy installation that enables you to access and secure your MySQL server via the command line interface.
The above is the detailed content of How to use rpm to install mysql on centos. For more information, please follow other related articles on the PHP Chinese website!