Hi People. Everyone ever make a wrong decision, that can make a trouble. At this time i get error about mysql. Human error that force mysql server to reset root password.
root@ip-10-179-164-79 ~# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
Solution:
- Stop service mysql. And run mysql in safe mode
root@ip-10-179-164-79 ~# /etc/init.d/mysqld stop
root@ip-10-179-164-79 ~# mysqld_safe –skip-grant-tables & mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where User=’root’;
mysql> flush privileges;
mysql> quit
- Restart service mysql.
root@ip-10-179-164-79 ~# /etc/init.d/mysqld stop
root@ip-10-179-164-79 ~# /etc/init.d/mysqld start
Once after setting the password even again I have encountered the below error and then set the password , try login again from the operating system level.
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> use mysql;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> update user set password=PASSWORD(“root1234”) where User=’root’;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
Even finished update user root password, still can not login mysql. Finally use global config SET PASSWORD
.
root@ip-10-179-164-79 ~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.16
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> SET PASSWORD = PASSWORD(‘root1234’);
Try to login mysql root again.
root@ip-10-179-164-79 ~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test |
+——————–+
4 rows in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
That is my note about mysql reset root password. May be it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it.