Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

来源:互联网 发布:什么叫绿鞋机制知乎 编辑:程序博客网 时间:2024/06/02 19:43
转自VC错误:http://www.vcerror.com/?p=1643
问题描述:

操作系统 :Red Hat Enterprise Linux Server release 5.7 (Tikanga) 64 bit

数据库版本 : Mysql 5.6.19 64 bit

安装了Mysql 5.6.19 64bit 版本的数据库,安装成功了,但是使用root登录时遇到了ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)错误. 如下所示


[root@DB-Server tmp]# rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpm 
Preparing... ########################################### [100%]
   1:MySQL-server ########################################### [100%]
[root@DB-Server tmp]# rmp -ivh MySQL-client-5.6.19-1.rhel5.x86_64.rpm 
-bash: rmp: command not found
[root@DB-Server tmp]# rpm -ivh MySQL-client-5.6.19-1.rhel5.x86_64.rpm 
Preparing... ########################################### [100%]
   1:MySQL-client ########################################### [100%]
[root@DB-Server tmp]# /etc/rc.d/init.d/mysql status
MySQL is not running[FAILED]
[root@DB-Server tmp]# /etc/rc.d/init.d/mysql start
Starting MySQL.[  OK  ]
[root@DB-Server tmp]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@DB-Server tmp]# mysql -u root mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)  


安装过程中没有设置过root密码,不清楚root密码,搜索了网上一些资料,大致有下面一些情况:


1:有些博客说root的随机密码位于/root/.mysql_secret中,但是我这个版本根本没有/root/.mysql_secret文件。搜索到一篇文章,大意如下所示(没有确认)。到现在也没有明白,我这个版本为什么没有生成这个文件?


ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) :表示没有生成root的临时密码


ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) :表示生成了root的临时密码。


2:有些资料说root的默认密码为空,经过确认那是以前的老版本,Mysql 5.6及以后版本出处于安全考虑,root密码已经不为空了。



解决方法:
具体的解决方法参考文章:http://www.vcerror.com/?p=1640
0 0