mysql 5.6  安装后无法登录

 

安装完mysql之后,mysql没有生成具有空密码的root。
而是生成一个/root/.mysql_secret 文件 。
这个文件中有root密码,mysql安装时自动生成的。


[root@localhost ~]# cat /root/.mysql_secret
# The random password set for the root user at Thu Jun 19 03:45:15 2014 (local time): wb3x93cF6PoT9RfI

# The random password set for the root user at Thu Jun 19 22:44:36 2014 (local time): JbuxUpBzSJ20UTcQ

# The random password set for the root user at Thu Jun 19 23:18:57 2014 (local time): SY2pf_tC3v4YhH1x


这里选取最近时间生成的随机密码 。


用户第一次登录之后 需要更改密码
[root@localhost mysql]# 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.19

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;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> select * from mysql.user \G ;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
ERROR:
No query specified


直接使用 set password=password("") ;

 

我这里将密码设置为空了。


参考链接:http://tech.ddvip.com/2013-05/1368429043195354.html