Home > Database > Mysql Tutorial > How to reset MySQL Root password

How to reset MySQL Root password

黄舟
Release: 2017-09-06 14:57:42
Original
1380 people have browsed it

Reset Root password

Method 1:
Add in the [mysqld] field of my.ini:

skip-grant-tables
Copy after login


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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template