This article summarizes:
1. Create a new user and specify a password
2. Change the password
3. Forgotten Password Solution
Create a new user and specify a password
1) [Windows | linux] Mysql-uroot-p
Enter password:******
mysql> create user ' Keyman ' @ ' 127.0.0.1 ' identified by ' Keyman ';
Mysql> Grant Usage on * * to ' Harry ' @ ' 127.0.0.1 ' identified by ' Harry ';
Mysql> exit
[Windows | linux] mysql-ukeyman-pkeyman-h127.0.0.1
Mysql> exit
[Windows | linux] mysql-uharry-pharry-h127.0.0.1
MySQL changes the password method summarized as follows
1) [Windows | linux] Mysql-uroot-p
mysql> set password for ' Keyman ' @ ' 127.0.0.1 ' = password (' keyman123 ');
mysql> flush Privileges;
The following statement can only modify its own password
mysql> Set Password = password (' keyman123 ');
2) [Windows | linux] Mysql-uroot-p
Mysql> Grant Usage on * * to ' keyman ' @ ' 127.0.0.1 ' identified by ' keyman123 ';
3) [Windows | linux] mysql-uroot-h127.0.0.1-p password "New_password"
Solutions for forgetting passwords
1) Stop MySQL Database
[Windows] net stop MySQL
[Linux] service mysqld stop
2) Start the database in a way that does not load the authorization table
[Windows | linux] add below line to My.ini or my.cnf configuration file
[Mysqld]
......................
Skip-grant-tables
......................
[Windows] net start MySQL
[Linux] service mysqld start
3) Log in to the database and change the password
[Windows | linux] mysql-uroot mysql
mysql> Update user Set Password=password (' New_password ') where user = ' root ';
mysql> flush Privileges;
Mysql> exit
4) Restart the database
[Windows | linux] remove ' skip-grant-tables ' from configuration file
[Windows] net stop MySQL
[Windows] net start MySQL
[Linux] service mysqld restart
5) Login with the new password
[Windows | linux] Mysql-uroot-pnew_password
Mysql>
The above content is for reference only, if have the mistake, hope please understanding.
This article is from the "Keyman" blog, make sure to keep this source http://keyman.blog.51cto.com/9807984/1652372
MySQL Change password and forgot password how to deal with