MySQL forget the password can not log on approach

MySQL installed on a CentOS server.

1, first make sure the server for security of the state, that is, no one can arbitrarily connect to the MySQL database.
Because during the re-set the MySQL root password, MySQL database without password protection entirely out of
the state, other users can log on and modify any information MySQL. MySQL will be used to
port closed outside, and stops Apache and the method for all user processes to achieve quasi-secure server
status. Safest state Console above operation to the server, and to remove the cable.

2, MySQL login modify settings:
# Vim /etc/my.cnf
in [mysqld] section plus one: skip-grant-tables
for example:
[mysqld]
DATADIR = / var / lib / MySQL
Socket = / var / lib / MySQL / mysql.sock
Skip-Grant-the Tables
save and exit vi.

3. Restart mysqld
# Service mysqld restart
Stopping MySQL: [the OK]
Starting MySQL: [the OK]

4, log in and modify the MySQL root password
# MySQL
is available for purchase to at The MySQL Monitor Commands End with; or \ G..
Your MySQL Connection the above mentioned id is 3 to server version: 3.23.56
Type 'Help;'. Or '\ H' for Help type '\ C' to Clear The Buffer.
MySQL> the USE MySQL;
Database changed
MySQL> the UPDATE User the SET Password = password ( 'new new-password') the WHERE the User = 'the root ';
Query the OK, 0 rows affected (0.00 sec)
the rows Matched: 2 the Changed: 0 Warnings: 0
MySQL> the flush privileges;
Query the OK, 0 rows affected (0.01 sec)
MySQL> quit

. 5, the MySQL login setting changes back
# vim /etc/my.cnf
will just add in paragraph [mysqld] of skip-grant-tables to delete
save and quit vim

6, restart the mysqld
# Service mysqld restart
Stopping MySQL: [the OK]
starting MySQL: [the OK]

 

Guess you like

Origin www.cnblogs.com/deverz/p/10984631.html