MySQL forgot root password after processing

Source: Internet
Author: User

I found the password was wrong when I logged in to MySQL with the root user.

[Email protected] ~]# mysql-u root-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

Workaround

1. Stop MYSQLD Service

[[Email protected] ~]# service mysqld stop
Stop mysqld: [OK]


2. Execute Mysqld_safe--skip-grant-tables

[Email protected] ~]# Mysqld_safe--skip-grant-tables
140607 22:21:50 mysqld_safe Logging to '/var/log/mysqld.log '.
140607 22:21:50 Mysqld_safe starting mysqld daemon with databases From/var/lib/mysql

3. Log in to MySQL

[[email protected] ~]# MySQL
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.1.71 Source Distribution

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

4. Switch to MySQL database

mysql> use MySQL;
Reading table information for completion of table and column names
Can turn off this feature to get a quicker startup with-a

Database changed


5. more new password

mysql> Update user Set Password=password (' Redhat ') where user= ' root ';
Query OK, 2 rows Affected (0.00 sec)
Rows Matched:3 Changed:2 warnings:0

mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)

Mysql> exit
Bye

6. Restart the MYSQLD service


[Email protected] ~]# service mysqld restart
Stop mysqld: [OK]
Starting mysqld: [OK]

7. Log in with a new password

[Email protected] ~]# mysql-u root-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server version:5.1.71 Source Distribution

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

This article is from the "Cloud Life" blog, make sure to keep this source http://ovcer.blog.51cto.com/1145188/1423556

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.