Home >Database >Mysql Tutorial >How to reset MySQL Root password
Reset Root password
Method 1:
Add in the [mysqld] field of my.ini:
skip-grant-tables
Restart the mysql service. At this time, mysql does not require a password to log in to the database
Then enter mysql
mysql>use mysql; mysql> 更新 user set passw ord =password('新密码') WHERE User='root'; mysql> flush privileges;
After running, finally remove skip-grant-tables in my.ini and restart mysqld. .
Method 2:
Instead of modifying my.ini to restart the service, run mysql through non-service mode and add skip-grant-tables to modify the mysql password
Stop the mysql service
Open the command line window, in the bin directory Use mysqld-nt.exe to start, that is, execute in the command line window: mysqld-nt --skip-grant-tables
Then open another command line window and log in to mysql. You can enter without entering the mysql password.
After changing the password according to the above method, close the window where mysql is running on the command line. Mysql is closed at this time. If you find that mysql is still running
, you can end the corresponding process to close it.
Start mysql service
The above is the detailed content of How to reset MySQL Root password. For more information, please follow other related articles on the PHP Chinese website!