Home > Database > Mysql Tutorial > body text

How to install and configure MySQL in CentOS

WBOY
Release: 2023-06-03 16:16:44
forward
1405 people have browsed it

Step one: Install MySQL database

To avoid software package conflicts and incompatibilities, we should run the following command before installing MySQL to install the system The software package is upgraded to the latest version.

yum -y update

Next, execute the following command to install the MySQL database.

yum -y install mysql-server mysql

At this time, MySQL has been installed, and then we need to configure some MySQL.

Step 2: Configure the MySQL database

First, start the MySQL service.

systemctl start mysqld.service

Then, execute the following command to set MySQL to start automatically at boot.

systemctl enable mysqld.service

Next, we need to perform some security configuration on MySQL. This is very important, because security is often more important than convenience. Execute the following commands to configure security.

mysql_secure_installation

If you have not set the MySQL Root password, executing this command will prompt you to set the password. Then follow the instructions below.

  • Do you want to change the password of the root account? (Select yes)

  • What is your desired new password? (Enter new root password)

  • Enter the new password again to confirm (Re-enter new password)

  • Want to delete the anonymous user? (Select yes)

  • Disable remote Root login? (Select yes)

  • Delete the test database and let MySQL reload the permissions table? (Select yes)

At this point, we have completed the installation and basic configuration of MySQL.

Step 3: Use MySQL

Now we can run the following command to test whether MySQL can connect normally.

mysql -h localhost -u root -p

Enter the MySQL Root password you just set. After entering the MySQL shell, execute the following command to see if MySQL is working normally.

SHOW DATABASES;

If the system database can be displayed normally, it means that MySQL is installed and configured successfully.

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

Related labels:
source:yisu.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template