Monday, November 14, 2016

Unable to login (First time) after install mysql 5.7.16 - ERROR 1045 (28000): Access denied for user 'root'@'localhost'

Unable to login (First time) after install mysql  5.7.16
Problem:-

[root@exa1 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@exa1 ~]#
[root@exa1 ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@exa1 ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Solution: -
[root@exa1 lib]# grep 'temporary password' /var/log/mysqld.log
2016-11-08T22:48:17.341024Z 1 [Note] A temporary password is generated for root@localhost: qPbmqbe5Mp#J

[root@exa1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.16-log

Copyright (c) 2000, 2016, 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>