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