Table of contents
Step One: Add the MySQL Yum Repository
The fourth step is to start mysql and set it to boot
Step five, change the password
Step 6, Linux login and local login test
Step One: Add the MySQL Yum Repository
yum -y install https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
Step 2: Use yumyum makecache to download the package information of the server to the local computer and cache it
yum makecache
Step 3: Install mysql
sudo yum -y install mysql-community-server
Successful installation! ! ! !
The fourth step is to start mysql and set it to boot
Execute it first, and then execute the next step after the startup is successful. Set it to boot
systemctl start mysqld
Set boot
systemctl enable mysqld
Step five, change the password
First check the default generated password, the default password is the last output root@localhost: everything behind
sudo grep 'temporary password' /var/log/mysqld.log
Log in, and then the password is the one above that is automatically generated
mysql -uroot -p
Then the next step is to change the password, step by step
mysql>set global validate_password.policy=0;
mysql>set global validate_password.length=4;
mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password By 'newPassword'; # 修改密码
mysql>flush privileges;
mysql>update mysql.user set host = '%',plugin='mysql_native_password' where user = 'root'; # 全部主机都能访问
mysql>flush privileges;
mysql>exit;
#Note that the initialized password must conform to the length, and must contain numbers, lowercase or uppercase letters, and special characters.
If the following two errors are reported: ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run the following command first.
mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password By 'Huhjkha1@';
Step 6, Linux login and local login test