数据库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下的搭建过程