1. Download the RPM file for the yum installation

  • Open the MySQL Yum Repository download page

  • Click the [Download] Download button on the right of Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent)

  • Click on the link “No Thanks, Just Start my Download” at the bottom left to start the download

2. Install mysql8

  • Upload the downloaded RPM package to the/TMP directory of CentOS7

yum -y install /tmp/mysql80-community-release-el7-3.noarch.rpm

  • Yum install MySQL server

yum -y install mysql-community-server

  • Start the MySQL service

systemctl start mysqld.service

  • View the status of the service after it is started

systemctl status mysqld.service

  • Find the password of user root

grep "password" /var/log/mysqld.log

  • Connect to the database with the found initial password

mysql -uroot -p

  • Changing the Initial Password

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_12root'; SHOW VARIABLES LIKE 'validate_password%';

set global validate_password.policy=0; set global validate_password.length=1; ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

  • Example Set the mysql remote connection
mysql> use mysql;
mysql> update user set host="%" where user='root';
mysql> grant all privileges on test.* to root@'%';
mysql> GRANT ALL ON *.* TO 'root'@'%';
mysql> flush privileges;

Copy the code
  • Mysql client connection error:

  • The reason is that the encryption mode of mysql8 is caching_sha2_password. Change the encryption mode to mysql_native_password
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Copy the code