Opening nonsense:

While the student id card has not expired, I quickly started Tencent cloud for three years. Why should I use Tencent’s things? Is not because the others small program support okay? Without further ado, let’s get to the point.

MySQL yum yum yum

Centos7 does not have the yum source for MySQL. We download different versions of the source to install different versions of MySQL. You can choose to download it yourself or follow the selected commands below.

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
Copy the code

2. Install the downloaded RPM file

rpm -ivh mysql57-community-release-el7-8.noarch.rpm
Copy the code

Mysql > install Mysql

yum install mysql-server
Copy the code

Try logging in to MySQL

mysql -uroot -proot
Copy the code

This might be an error:

Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

Mysql: /var/lib/mysql: /var/lib/mysql: /var/lib/mysql: /var/lib/mysql

sudo chown -R xxx:xxx /var/lib/mysql
Copy the code

XXX indicates the current user name and the owning group

Restarting the MySQL service

service mysqld restart
Copy the code

5. Login fails. Obtain the initial password

cat /var/log/mysqld.log | grep password
Copy the code

A temporary password is generated for root@localhost: *** localhost:

mysql -uroot -p
Copy the code

Enter a password to log in

6. Change the initial password after successful login

set global validate_password_policy=0;
set global validate_password_length=4;
alter user 'root'@'localhost' identified by 'root’;
Copy the code

MySQL > install MySQL

Click on ❤ and pay attention if you like