1. Install MySQL's yum repository
Execute the following command:
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2. Install MySQL
dnf install mysql-community-server
3. Turn on MySQL service
service mysql start
4. Find the default password
To enhance security, MySQL5.7 randomly generates a password for the root user, in error log, about the location of the error log and, if the RPM package is installed, the default is/var/log/mysqld.log.
Only once you have started MySQL to view the temporary password, enter the following command to view the password:
grep 'temporary password' /var/log/mysqld.log
The output is as follows:
[[email protected]_0_13_centos init.d]# grep 'temporary password' /var/log/mysqld.log 2018-03-09T13:03:32.859149Z 1 [Note] A temporary password is generated for [email protected]: IVXhn:4E3uQ4
5. Log in to MySQL and change the password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';
Changing the password will appear:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Two global parameters must be modified:
First, modify the value of the Validate_password_policy parameter
Change the length of the password again
set global validate_password_length=1;
Execute the change password again.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';
6. Authorize other machines to connect
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'passwort' WITH GRANT OPTION; //passwort改为mysql登陆密码FLUSH PRIVILEGES;
7. Detailed description of password settings
Https://www.linuxidc.com/Linux/2016-01/127831.htm
CentOS7 installing MySQL using DNF