MySQL出错:ERROR 1045 (28000)的解决方法

MySQL突然不能用了,症状如下:

[root@bogon ok]# mysql
ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)
[root@bogon ok]# mysql
-uroot -p Enter password: ERROR 1045 (28000): Access denied for user root@localhost (using password: YES)
[root@bogon ok]#
/etc/init.d/httpd start 正在启动 httpd:
[root@bogon ok]#
/etc/init.d/mysqld restart 停止 mysqld: [确定] 正在启动 mysqld: [确定]
[root@bogon ok]# mysql ERROR
1045 (28000): Access denied for user root@localhost (using password: NO) [root@bogon ok]# mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user root@localhost (using password: YES)
解决方法:重改密码 [root@bogon ok]# /etc/init.d/mysqld stop 停止 mysqld: [确定]
[root@bogon ok]# mysqld_safe
--user=mysql --skip-grant-tables --skip-networking & [1] 10354 [root@bogon ok]# 150404 16:46:14 mysqld_safe Logging to /var/log/mysqld.log. 150404 16:46:14 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql [root@bogon ok]# mysql -u root mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A 。。。。。。。 Type help; or \h for help. Type \c to clear the current input statement. mysql>

[root@bogon ok]# mysql -u root -p
Enter password:

mysql>

问题解决。

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。