mysql5.7 generate random password after default, modify root user password
1. Modify Configuration parameters
Linux:/etc/my.cnf
Windows:c:\programdata\mysql\mysql Server 5.7\my.ini
Add a line under the [mysqld] section:Skip-grant-tables=1 This line of configuration lets mysqld not validate the password when it starts
Or add a command when you start the service: Service mysqld start--skip-grant-tables
2. Restart MySQL Service
Linux:service mysqld Restart
Windows:net Start/stop MySQL57
3. Log in to MySQL using the root user:
Linux:mysql-u Root
Windows: You must start cmd with administrator privileges, switch to C:\Program files\mysql\mysql Server 5.7\bin,mysql-u root-p
4, switch to the MySQL database, update the user table, the user table has all the information saved
Update user set Password=password (' root ') where user= "New_password";
Alter user ' root ' @ ' localhost ' identified by ' new_password ';
Update user Set authentication_string = password (' new_password '), password_expired = ' n ', password_last_changed = Now () WH ere user = ' root ';
Note: In previous versions, the field name of the password field was password,5.7 to authentication_string
5. Exit MySQL, edit the/etc/my.cnf or C:\ProgramData\MySQL\MySQL Server 5.7\my.ini file, delete the Skip-grant-tables=1 line
MySQL three exit commands: Exit; Quit; \q;
6, restart the Mysqld service, and then login with the new password can
Note: MySQL 5.7 generates a random initial password after initial installation (Centos7 OS), and is recorded in the/var/log/mysqld.log, can be viewed through the cat command, find the password keyword found password
MySQL5.7 Change the default password, random password