Home >Database >Mysql Tutorial >centos yum mysql installation

centos yum mysql installation

王林
王林Original
2023-05-18 14:10:08630browse

CentOS is one of the enterprise-level Linux operating systems with a wide range of applications, including web servers or database servers, and MySQL is a very popular open source database management system. In this article, we will learn how to install MySQL on CentOS using yum package manager.

General steps

Before you start installing MySQL, you need to make sure that your CentOS is connected to the Internet and has permission to use the root user.

  1. Update yum package

Before using the yum package manager, it is best to make sure that your system has been updated to the latest version. Type the following command in the terminal:

sudo yum update

After entering the password, wait for the system to be updated. If there are updated software packages, they will be listed.

  1. Installing MySQL

Next, we can use yum to install the MySQL server and client.

sudo yum install mysql-server mysql-client

After entering y, yum starts to download MySQL and install it. After the installation is complete, we need to start the MySQL service and automatically start MySQL when the system starts.

sudo systemctl start mysqld.service
sudo systemctl enable mysqld.service

This will start the MySQL server and add it to the system services.

  1. Configuring MySQL

The default configuration file for MySQL is /etc/my.cnf. You can modify this file to customize the configuration of the MySQL server.

To change MySQL's default password policy, you can edit the my.cnf file. Please add the following to the [mysqld] section:

validate_password_policy=LOW

This will disable MySQL password policy enforcement. After saving the changes, please restart the MySQL service.

sudo systemctl restart mysqld.service

During the installation process, MySQL also provides a default root user and password. You can log in using the following command:

mysql -u root -p

However, if you follow the steps above to change the password policy, then You need to first change the password of the root user through the following command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Now, you can access the database through the MySQL client.

Summary

Installing MySQL on CentOS is very simple. If you are not using MySQL in a production environment, consider installing it on your local computer for testing and experience. Don't forget to adjust the default configuration as needed and change the MySQL user and password according to your workflow.

The above is the detailed content of centos yum mysql installation. 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
Previous article:How to enter mysqlNext article:How to enter mysql