1. Stop the MySQL program
[email protected] ~]# service mysqld stopstopping mysqld: [ OK ]
2. Open the MySQL configuration file
[Email protected] ~]# VIM/ETC/MY.CNF
Search Mysqlld /mysqld
[Mysqld] #下一行添加
Skip-grant-tables #忽略MySQL权限问题, log in directly
3. Turn on MySQL service
[[Email protected] ~]# service mysqld start
4. No password directly into MySQL
[Email protected] ~]# Mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 2Server version:5.1.73-log Source distributioncopyright (c), +, Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
5. Use the MySQL table to change the password
mysql> use MySQL Database changedmysql> Update user set Password=password ("123") where user= "root"; #密码修改为123Query OK, 3 rows A Ffected (0.00 sec) Rows matched:3 changed:3 warnings:0
6. Refresh Permissions
mysql> flush Privileges; Query OK, 0 rows Affected (0.00 sec)
7. Kill all Mysqld processes
[[email protected] ~]# killall mysqld[[email protected] ~]# ps-ef|grep mysqldroot 53342 45198 0 20:57 pts/6< c3/>00:00:00 grep mysqld
8. Turn on mysqld service
[[Email protected] ~]# service mysqld startstarting mysqld: [ OK ]
9. Test into MySQL
[Email protected] ~]# mysql-u root-penter password:welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 2Server version:5.1.73-log Source distributioncopyright (c), +, Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>
Linux Reset mysql Password