Solve the Problem of forgetting the MYSQL database ROOT password on the CentOS Server
For various reasons, the lost MYSQL password or locally stored MYSQL database password may exist, and the problem is not terrible, we only need to find a proper solution to the problem. In the morning, a netizen used the LLsMP one-click package to build the VPS site environment. Some users could not find the ROOT password of the MYSQL database and could not manage the PHPMYADMIN database. This is not the time to sort out the solution, so that you can solve similar problems in the future.
1. Modify MYSQL Logon Settings
Vi/etc/my. cnf
Edit the my. cnf file and add a line of skip-grant-tables to [mysqld.
Add, And then: wq save and exit.
2. Restart MYSQLD
/Etc/init. d/mysqld restart
3. Prepare to change the MYSQL password
[Root @ localhost ~] #/Usr/bin/mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution
Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-
Database changed
Mysql> UPDATE user SET Password = password ('laozuo. org ') WHERE User = 'root ';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Bye
The red part is what we need to enter. Set the password to laozuo.org. You can define a new password or modify it later.
4. Edit the/etc/my. cnf File
Delete the added skip-grant-tables line, and save and exit.
Finally, restart MYSQLD.
/Etc/init. d/mysqld restart
After MYSQLD is restarted, We can log on to MYSQL management through PHPMYADMIN, and log on with the Reset Password.