A How to reset the root password after forgetting the root password of MySQL
1. Edit the MySQL configuration file:
In the Windows environment:%mysql_installdir%\my.ini//mysql The My.ini configuration file under the installation directory.
Linux Environment:/ETC/MY.CNF
Add the following line to the [MySQLd] configuration segment: Skip-grant-tables
Save to exit Edit.
2. Then restart the MySQL service
In the Windows environment:
net stop MySQL
net start MySQL
In a Linux environment:
/etc/init.d/mysqld restart
3. Set a new root password
Then execute it under the cmd command line:
Mysql-uroot-p MySQL
When you require a password, enter the database directly without a password.
Now we execute the following statement to update the root password to 123456:
Update user set Password=password ("123456") where user= ' root '
Quit MySQL.
4. Restore the configuration file and restart the service
Then modify the MySQL configuration file to delete the line you just added (skip-grant-tables).
Restart the MySQL service again to
Two Modify the MySQL username and password: (not confirmed)
Method One: (for Administrators or users with global permissions to reset other user's password)
Enter command line mode
Mysql-u Root MySQL
mysql> UPDATE user SET Password=password ("New password") WHERE user= ' name '
Mysql> FLUSH Privileges
Mysql> QUIT
Method Two: (Apply ibid., only method is different)
Mysql-u Root MySQL
Mysql> SET PASSWORD for Name=password (' New PASSWORD ')
Mysql> QUIT
The last must kill skill:
mysqladmin-u root "Old password" "New password"
Note: Please use your username to replace the above name, new password Please enter the password you want to set.
MySQL Reset root password