Home  >  Article  >  Database  >  How to install MySQL on CentOS system

How to install MySQL on CentOS system

PHPz
PHPzOriginal
2023-04-19 17:25:35671browse

In the CentOS operating system, you need to follow specific steps to install MySQL. In this article, we will introduce you how to install MySQL on CentOS system.

Step 1: Update the software package
Before installing MySQL, it is best to update the software package to ensure that the system is up to date. You can use the following command to update the package:

sudo yum update

Step 2: Add MySQL Community Package
MySQL Community provides its own package, which needs to be added to install MySQL. Run the following command to add the MySQL community package:

sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

Step 3: Install MySQL
Now you can use the following command to install MySQL:

sudo yum install mysql-community-server

Executing this command will automatically download and Install MySQL. When the MySQL installation is complete, you need to start the MySQL service:

sudo systemctl start mysqld

Run the following command to check if the MySQL service is running:

sudo systemctl status mysqld

Step 4: Configure MySQL
After completing the MySQL installation , you need to configure the initial password of the root user for MySQL. MySQL's root user does not have a password set by default, you need to set a password for it to make it more secure.

To configure the root user password for MySQL, use the following command:

sudo mysql_secure_installation

This command will set the password for the root user and perform other security settings.

Step 5: Log in to MySQL
After installing and configuring MySQL, you can now log in to the MySQL server using the following command:

mysql -u root -p

This command will prompt you for a password to log in to the MySQL server .

Step 6: Upgrade MySQL
Sometimes you may need to upgrade MySQL to make it more stable and functional. To upgrade MySQL, use the following command:

sudo yum update mysql-community-server

After executing this command, MySQL will be updated to the latest version and automatically convert all data files to the latest format.

Summary
MySQL is a very popular database management system that is widely used in many fields. CentOS operating system is a very popular Linux version and it is one of the excellent hosting platforms for MySQL. With the steps in this article, you can simply install and configure MySQL on your CentOS system.

The above is the detailed content of How to install MySQL on CentOS system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn