When you log in to a database, you may forget your password.
Method: Edit the MySQL configuration file, do not allow MySQL to authorize, and then enter MySQL no user login, because it is the root user, so in the MySQL library password reset
MySQL password reset process and statements:
[Email protected] ~]# mysql-uroot
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
Do not enter password login will error
[Email protected] ~]# vim/etc/my.cnf
[Mysqld]
Skip-grant
Add Skip-grant under the Mysqld module to not allow MySQL to authorize any user
Save exit, then restart/etc/init.d/mysqld restart
[Email protected] ~]# mysql-uroot
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.1.40-log MySQL Community Server (GPL)
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
mysql> use mysql
Database changed
mysql> Update user set Password=password (' 123456 ') where user= ' root ';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect ...
Connection Id:3
Current Database:mysql
Query OK, 3 Rows Affected (0.00 sec)
Rows Matched:3 Changed:3 warnings:0
This time the root user's password becomes 123456, do not forget to delete the configuration file in the Skip-grant, and then restart MySQL can enter a new password to login
[Email protected] ~]# mysql-uroot-p123456
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.1.40-log MySQL Community Server (GPL)
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
This article is from the "Parody Games" blog, so be sure to keep this source http://kevinjin117.blog.51cto.com/11655131/1835795
Root password reset for Lamp-mysql