The linux administrator may forget the mysqlroot password. perform the following steps to reset the MySQL root Password: 1. first, make sure that the server is in a secure state, that is, no one can connect to the MySQL database at will. Because during the resetting of the MySQL root Password, the MySQL database is completely out of password-free
The linux administrator may forgetMysql root PasswordYou can perform the following steps to resetMySQL root Password:
1. First confirm that the server is in a secure state, that is, no one can connect to the MySQL database at will.
Because, during the resetting of the MySQL root Password, the MySQL database is completely out of password-free
Other users can log on to and modify MySQL information as needed. You can use
The external port is closed, and Apache and all user processes are stopped to implement server quasi-security.
Status. The safest status is to operate on the server Console and unplug the network cable.
2. Modify MySQL Logon Settings:
# Vi/etc/my. cnf
In the [mysqld] section, add skip-grant-tables.
For example:
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
Skip-grant-tables
Save and exit vi.
3. Restart mysqld
#/Etc/init. d/mysqld restart
StopPingMySQL: [OK]
Starting MySQL: [OK]
4. log on to and modify the MySQL root Password
#/Usr/bin/mysql
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connectionIdIs 3 to server version: 3.23.56
Type 'help; 'or 'H' for help. Type 'C'ClearThe buffer.
Mysql> USE mysql;
Reading table infoRmAtion for completion of table andColUmn names
You can turn off this feature to get a quicker startup with-
Database changEd
Mysql> UPDATE user SET Password = password ('new-password') WHERE User = 'root ';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
Mysql> quit
Bye
5. Modify the MySQL Logon Settings.
# Vi/etc/my. cnf
Delete the skip-grant-tables added to the [mysqld] section.
Save and exit vi.
6. Restart mysqld
#/Etc/init. d/mysqld restart
Stopping MySQL: [OK]
Starting MySQL: [OK]
7. restore the normal working status of the server
Perform the inverse operation in step 1. Restore the server's working status.