解决Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'问题

数据库root好久不登录,结果提示

Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'

找了很多博客,发现下面这段是管用的,贴出来,也让小伙伴少走弯路


First things first. Log in as root and stop the mysql daemon. 


sudo /etc/init.d/mysql stop
 

Now lets start up the mysql daemon and skip the grant tables which store the passwords.

sudo mysqld_safe --skip-grant-tables&

(press Ctrl+C now to disown the process and start typing commands again)

You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

sudo mysql --user=root mysql

update user set Password=PASSWORD('new-password');
flush privileges;
exit;
 

Now kill your running mysqld then restart it normally. 

sudo killall mysqld_safe&
(press Ctrl+C now to disown the process and start typing commands again)
/etc/init.d/mysql start

You should be good to go. Try not to forget your password again


参考博文:

1:    http://blog.csdn.net/zl17/article/details/8589454 介绍的比较详细

2:   http://www.cnblogs.com/khler/archive/2011/02/10/1950819.html  介绍的很是系统,把各种情况都列了出来

3:  另外再贴一篇文章,http://blog.csdn.net/fyq891014/article/details/17360245  这篇博文作者很详细的说命了mysql在centOS下的搭建过程



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值