Unable to logon to mysql with root. Force to change the password.
-bash-4.1$ mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
-bash-4.1$ su -
Password:
[root@baja ~]# su - mysql
-bash-4.1$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.6.21 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> UPDATE mysql.user SET Password=PASSWORD('newpassword999') WHERE User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
<<<user can test this on a different terminal, it should still error out with 1045, so the next flush privileges is crucial>>>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
<<<test this again in another terminal, user should be able to logon fine now>>>
mysql> quit
Bye
-bash-4.1$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.6.21 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>
Using mysqladmin to reset root password at worst case.
-bash-4.1$ mysqladmin -u root password [pass321]
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
-bash-4.1$ mysqladmin -u root password
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
-bash-4.1$ exit
logout
[root@baja ~]# mysqladmin -u root password
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
[root@baja ~]# mysqladmin -u root password -p
Enter password:
New password:
Confirm new password:
[root@baja ~]#
No comments:
Post a Comment