1, first turn off MySQL, using the '--skip-grant-tables ' parameter to start mysqld
[[Email protected] ~] #service mysqld stop[[email protected] ~]#/usr/bin/safe_mysqld--skip-grant-tables&
2, at this time can no password login mysql, change password
[[Email protected] ~] #mysql-urootmysql>update user set Password=password ("New_pass") where user= "root"; Mysql>flush privileges;
The password modification was successful.
Now you want to turn off MySQL
[[Email protected] ~]# service mysqld stopstopping mysqld: [OK]
The command executed successfully, but
[[email protected] ~]# netstat-tnlp|grep mysqltcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 13916/m Ysqld
Discover MySQL port still exists, view process
[[email protected] ~]# ps-ef |grep mysql |grep-v grepmysql 13916 12911 0 11:42 pts/3 00:00:00 mysqld--skip-grant -tables
Finally use Mysqladmin shutdown to close successfully
[Email protected] ~]# mysqladmin-uroot-ppassword-s/var/lib/mysql/mysql.sock shutdown
MySQL forgot root password