mysql5.6 forgot the database root password:
[root@oraserver139 ~]# Mysql-uroot-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
To view the currently installed version of MySQL:
root@oraserver139 ~]# Rpm-qa | grep MySQL
Mysql-server-5.6.15-1.el6.x86_64
Mysql-client-5.6.15-1.el6.x86_64
Mysql-shared-compat-5.6.15-1.el6.x86_64
Mysql-devel-5.6.15-1.el6.x86_64
Perl-dbd-mysql-4.022-1.el6.rfx.x86_64
Stop MySQL Service:
[root@oraserver139 ~]# service MySQL Stop
Shutting down MySQL. success!
Enter into Skip-grant-tables mode:
[root@oraserver139 ~]# Mysqld_safe--skip-grant-tables
140211 15:37:49 mysqld_safe Logging to '/var/lib/mysql/oraserver139.err '.
140211 15:37:49 Mysqld_safe starting mysqld daemon with databases From/var/lib/mysql
Now you don't need a password to get into MySQL:
[root@oraserver139 ~]# MySQL
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.6.15 MySQL Community Server (GPL)
Copyright (c), 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark the Oracle Corporation and/or its
Affiliates. Names may trademarks of their respective
Owners.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Access to MySQL system database:
mysql> use MySQL
Reading table information for completion of table and column names
You can turn off the feature to get a quicker startup with-a
Database changed
To modify the root account password:
mysql> Update user Set Password=password ("12345") where user= "root";
Query OK, 4 rows Affected (0.02 sec)
Rows Matched:4 Changed:4 warnings:0
Refresh permissions:
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
Mysql> exit
Bye
To stop the MySQL process:
[1]+ Stopped Mysqld_safe--skip-grant-tables
Start MySQL:
[root@oraserver139 ~]# service MySQL start
Starting MySQL success!
Use the password you just modified to enter MySQL:
[root@oraserver139 ~]# mysql-uroot-p12345
Warning:using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server version:5.6.15
Copyright (c), 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark the Oracle Corporation and/or its
Affiliates. Names may trademarks of their respective
Owners.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD (' 12345 ');
Query OK, 0 rows Affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.00 sec)
Modification completed;
The above is a small set to introduce Mysql5.6 forget root password to modify the root password method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!