Correct Solution for forgetting the root password in the mysql tutorial
This article describes the correct solution for mysql to forget the root password. We all know that the password is missing during actual operations.
This is a headache. The following are the correct solutions for this problem.
In the future, there will be no small gains.
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 filesmysqlmysql server 5.0bin>
Run: mysqld-nt -- skip-grant-tables
Open a command line window and execute mysql
> Use mysql # select a database tutorial
1.> update user set passwordpassword = password ("new_pass") where
User = "root ";
2.> flush privileges;
3.> exit
Use ctrl + alt + del to find the mysqld-nt process and kill it. Restart the mysql-nt Service.
Log on with a 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
1.> use mysql
2.> update user set passwordpassword = password ("new_pass") where
User = "root ";
3.> 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 yes
Mysqld_safe)
You can access mysql without a password.
Then/usr/local/mysql/bin/mysql
1.> use mysql
2.> update user set passwordpassword = password ("new_pass") where
User = "root ";
3.> flush privileges;
Kill mysql again and start mysql in a normal way.