What if Mysql forgets the root password?
Sometimes it is sad that MySQL forgets the root password. In this case, how can we reset the root password?
Find and edit the my. ini configuration file of mysql, and add skip-grant-table to the mysqld node as follows:
# These let you safely reset the lost root password.skip-grant-table
Save the changes and restart the mysql service.
Now you can connect to the database without the root password. Then, execute the following update:
USE mysql;UPDATE USERSET password = password('yournewpasswordhere')WHERE USER = 'root'AND host = 'localhost';
In this way, the root password is changed. At this time, delete the skip-grant-table in my. ini and restart mysql service.
The following describes how to reset passwords in 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.
Articles you may be interested in:
- Mysql root User Password modification and Elimination
- How does one forget the root password for mysql in windows?
- Reset the root password of the MySQL database (linux/windows)
- MYSQL root Password modification command Summary
- How to reset the root user password of a mysql database
- Force-Modify mysql root Password six ways to share (mysql forgot password)
- How to solve the problem that mysql forgets the root password in windows
- How to view or modify the Root password of Mysql)
- MySQL-four methods for modifying the root password (take windows as an example)
- Resetting mysql root Password (available for test)
- How to change the root password without restarting Mysql
- How to change the default mysql null password (root password) in xampp
- One-Click Reset mysql root Password implementation script