Home  >  Article  >  Database  >  Analysis of installing MySQL instance in CentOS7

Analysis of installing MySQL instance in CentOS7

WBOY
WBOYforward
2023-06-03 09:34:02852browse

1. Download and install the MySQL source

yum -y install wget https://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

Analysis of installing MySQL instance in CentOS7

2. Check whether mysql-community exists under

in /etc/yum.repos.d. repo and mysql-community-source.repo

Analysis of installing MySQL instance in CentOS7

3. Install MySQL

yum -y install mysql-community-server

Analysis of installing MySQL instance in CentOS7

If you encounter the following at this time Error:

"Public key for mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm is not installed

Failing package is: mysql-community -libs-compat-5.7.37-1.el7.x86_64

GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql”

Analysis of installing MySQL instance in CentOS7

#The reason for the above situation is that MySQL's GPG has been upgraded and needs to be obtained again.

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

Analysis of installing MySQL instance in CentOS7

Then re-execute the "yum -y install mysql-community-server" command to install it.

Analysis of installing MySQL instance in CentOS7

4. Start the MySQL service

Start the service:

systemctl start mysqld

If you need to set it to start automatically at boot:

systemctl enable mysqld

5. After the installation

will automatically generate a random password in /var/log/mysqld.log, obtain the password

grep 'temporary password' /var/log/mysqld.log

Use the obtained random password to log in to the MySQL client.

mysql -uroot -p

Analysis of installing MySQL instance in CentOS7

6. Set MySQL password security policy

Password strength and length (4 represents the lowest level, when the length is less than 4, the value is still 4 ) are set to the lowest level and change the password.

Password strength:

  • 0: low level, only check the length;

  • 1 : Medium level (default), length 8, and must contain numbers, uppercase and lowercase letters, and special characters;

  • 2: Strong level, needs to include a dictionary file.

set global validate_password_policy=0; 
set global validate_password_length=4;
alter user 'root'@'localhost' identified by '123456';

Analysis of installing MySQL instance in CentOS7

7. Set up remote login

Create user:

create user 'root'@'%' identified by '123456';

Allow remote connection:

grant all privileges on *.* to 'root'@'%' with grant option;

Refresh permissions:

flush privileges;

Analysis of installing MySQL instance in CentOS7

The above is the detailed content of Analysis of installing MySQL instance in CentOS7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete