Root password reset for Lamp-mysql

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.