In the Windows environment
1. Kill all the MySQL processes
A. Through DOS command: NET start and net stop MySQL
B. Services through the Control Panel
2. In the DOS prompt box, locate the path to the MySQL installation directory such as: C:\mysql\bin
In console input: mysqld--skip-grant-tables//over root permissions
After the carriage return, there is no display, indicating success
3. Reopen a DOS prompt box, enter mysql-u root-p in the box to login without password
4. Modify the MySQL password
Enter the following command
>use MySQL
>update User Set Password=password ("New_pass") where user= "root";
>flush privileges;
You can also do this: mysqladmin-h hostname-u user password ' new password '.
In the load permissions ' mysqladmin-h hostname flush-privileges ', or use the SQL command ' flush privileges '.
5. Exit
Input \q
6. Re-enter MySQL with the newly modified password
Under the Linux environment:
1. Terminal input VI/ETC/MY.CNF
Enter to change, add in [MYSQLD] Paragraph
Skip-grant-tables Save exit
2. Restart the MySQL service
Service mysqld Restart
3. Log in to MySQL
Terminal input: MySQL Enter login
After entering MySQL, enter:
Use MySQL;
Update user set Password=password (' New password ') where user= ' root ';
Flush privileges;
Quit
Quit MySQL
4. Enter vi/etc/my.cnf again
Change back to the original state, remove Skip-grant-tables, save exit
5. Restart the MySQL service
Service mysqld Restart, login with new password
Reprint url:http://mrhouzhibin.blog.163.com/blog/static/1945962412011926112959446/
MySQL database forgot password "reprint"