The following articles mainly introduce the correct solution for MySQL to forget the root password. We all know that it is a headache to forget the password in actual operations, the following is the correct solution to this problem. I hope you will get a lot of benefits after browsing.
MySQL root Password forgot solution:
In windows:
Open the command line window and stop MySQL service: Net stop MySQL
Start MySQL, usually to the installation path of MySQL, find the MySQLd-nt.exe
To this directory:
C: \ Program Files \ MySQL Server 5.0 \ bin>
Run: MySQLd-nt -- skip-grant-tables
Open a command line window and execute MySQL
> Use MySQL # select a database
- >update user set passwordpassword=password("new_pass") where user="root";
- >flush privileges;
- >exit
Use Ctrl + Alt + Del to find the MySQLd-nt process and kill it. After restarting the MySQL-nt service, you can log on with the new password.
Solution for MySQL to forget the root password: in linux:
If MySQL is running, killall-TERM MySQLd is first killed.
Start MySQL: bin/safe_MySQLd -- skip-grant-tables &
You can access MySQL without a password.
Then
- >use MySQL
- >update user set passwordpassword=password("new_pass") where user="root";
- >flush privileges;
Kill MySQL again and start MySQL in a normal way.
If MySQL is running, killall-TERM MySQLd is first killed.
Start MySQL: bin/safe_MySQLd -- skip-grant-tables & (sometimes MySQLd_safe)
You can access MySQL without a password.
Then/usr/local/MySQL/bin/MySQL
- >use MySQL
- >update user set passwordpassword=password("new_pass") where user="root";
- >flush privileges;
Kill MySQL again and start MySQL in a normal way.
The above content is an introduction to MySQL's "Forgot root". I hope you will have some gains.