First, if the database is the initial landing
The Linux system generates a raw password for the database in the file/var/log/mysqld.log:
grep "Temporary password"/var/log/mysqld.log find the original password
Login #mysql-uroot-p ' The password you found '
Mysql>set Global validate_password_policy=0//Set Password Authentication policy
Mysql>set Global validate_password_length=6//Set password length at least 6 bits
Mysql>alter user [email protected] "localhost" identified by "123456"//Set Password I'm the key to remember the initial setup, you must alter the password
Restart the service and log in again to Systemctl restart Mysqld mysql-uroot-p123456
For password authentication policy above is a one-time, permanent settings need to set the configuration file
Vim/etc/my.cnf
[MySQL]
Validate_password_policy=0
Validate_password_length=6
: Wq
Restart the service to
Second, if the database non-initial landing:
Modify the configuration file, skip the monitoring of the Password monitoring table
Vim/etc/my.cnf
[MySQL]
Skip_grant_tables
#validate_password_policy =0
#validate_password_length =6
: Wq
Restart Service Systemctl Restart Mysqld
Modify the value of the field that stores the database password after entering the database
This field is authentication_string in the user table in the MySQL library
#mysql
Mysql>update Mysql.user Set Authentication_string=password ("New password you want to set") where user= "root"
and host="localhost";//////我是解释分割 password()是mysql自带的加密函数,因为mysql不可能把你的密码铭文存 储在自己的表里
Mysql>flush privileges;//////I was explaining that the split flush is refreshing, this step is the refresh permission, that is, your password changes stored in the process of the table, Essential!!! Otherwise, the new password will be updated in white.
After exiting the database, modify the configuration file without skipping the password monitoring table and logging in with your new password
Mysql>exit
Vim/etc/my.cnf
[Mysqld]
#skip_grant_tables
Validate_password_policy=0
Validate_password_length=6
: Wq
#systemctl Restart Mysqld
#mysql-uroot-p New Password
Iii. Important additions:
When you write a password policy, you want to monitor whether the variable
#find/-name "validate_password.so"
have, the following results can be found, according to one or two operation
/usr/lib64/mysql/plugin/debug/validate_password.so
/usr/lib64/mysql/plugin/validate_password.so
If the query has no results, install the plugin and modify the configuration file followed by one or two operations, as follows:
Modify configuration file: Vim/etc/my.cnf
[Mysqld]
plugin-load=validate_password.so///I'm explaining split line: Load plugin
Validate-password=force_plus_permanent////I'm explaining. Split line: Force installation to prevent the plugin from being deleted at run time
To install the plugin:
mysql> INSTALL PLUGIN validate_password SONAME ' validate_password.so ';
Restart the service and monitor for installation success:
Systemctl Restart Mysqld
#find/-name "validate_password.so"
What does the MySQL password forget?