I. Windows cracking:
1. Stop the mysql Service
2. Enter the command window, enter the bin directory under the mysql installation directory, skip permission detection, and start mysql
Mysql \ bin> mysqld-nt -- skip-grant-tables
3. open a new window, go to the bin directory, and set a new root password.
Mysql \ bin> mysqladmin-u root flush-privileges password "newpassword"
Mysql \ bin> mysqladmin-u root-p shutdown prompts you to enter the password and enter newpassword to enter the database
4. Stop mysql server, start mysql in normal mode, and then use the above account to log on to the database.
Ii. Linux cracking:
Vi/etc/my. cnf # add a line of skip-grant-tables in it # Save and exit # restart mysql services mysql restart # You do not need to password mysql-uroot-p when logging on to mysql # modify the root password of mysql use mysql; update user set password = password ('000000') where user = 'root'; # Last
Vi/etc/my. cnf
# Add a row in it
Skip-grant-tables
# Save and exit
# Restart the mysql Service
Services mysql restart
# You do not need a password to log on to mysql.
Mysql-uroot-p
# Modifying the mysql root Password
Use mysql;
Update user set password = password ('000000') where user = 'root ';
# Last refresh permission
Flush privileges
Quit
Solution to Mysql5.0 root Password loss