What should I do if I forget my MySQL password? MySQL root Password Reset method, mysqlroot
MySQL sometimes forgets the root password. Here we provide a password reset method for Windows and Linux.
Windows:
1. log on to the system as a system administrator.
2. Open cmd ----- net start to check whether mysql is started. If it is enabled, the net stop mysql will be stopped.
3. Install mysql in d: \ usr \ local \ mysql4 \ bin.
4. Skip the permission check and start mysql.
D: \ usr \ local \ mysql \ bin \ mysqld-nt -- skip-grant-tables
5. Open cmd again. Enter d: \ usr \ local \ mysql4 \ bin:
D: \ usr \ local \ mysql \ bin \ mysqladmin-u root flush-privileges password "newpassword"
D: \ usr \ local \ mysql \ bin \ mysqladmin-u root-p shutdown prompts you to re-enter the password.
6. net start mysql in cmd
7. You have done it.
Linux:
One of the methods to restore the MySQL root Password
If you forget the MySQL root Password, use the following method to reset it:
1. KILL the MySQL process in the system;
Killall-TERM MySQLd
2. Run the following command to start MySQL without checking its permissions;
Safe_MySQLd -- skip-grant-tables &
3. Use the empty password to log on to MySQL as the root user;
MySQL-u root
4. Modify the password of the root user;
MySQL> update MySQL. user set password = PASSWORD ('new password') where User = 'root ';
MySQL> flush privileges;
MySQL> quit
Restart MySQL to log on with the new password.
MySQLroot password restoration method 2
It is possible that your system does not have the safe_MySQLd Program (for example, I am using the ubuntu operating system, MySQL installed with apt-get). The following method can be restored:
1. Stop MySQLd;
Sudo/etc/init. d/MySQL stop
(You may have other methods. Simply stop running MySQLd)
2. Run the following command to start MySQL without checking its permissions;
MySQLd -- skip-grant-tables &
3. Use the empty password to log on to MySQL as the root user;
MySQL-u root
4. Modify the password of the root user;
MySQL> update MySQL. user set password = PASSWORD ('newpassword') where User = 'root ';
MySQL> flush privileges;
MySQL> quit
Restart MySQL
/Etc/init. d/MySQL restart
You can use the new password newpassword to log on.
The above describes how to reset the root password of MySQL. I hope you can learn more about MySQL syntax and follow MySQL 5.1 reference manual.