关闭

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

149人阅读 评论(0) 收藏 举报
分类:

解决办法:

这种问题需要强行重新修改密码,方法如下:


/etc/init.d/mysql stop   (service mysqld stop )
/usr/bin/mysqld_safe --skip-grant-tables

另外开个SSH连接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit

pkill -KILL -t pts/0 可将pts为0的**用户(之前运行mysqld_safe的用户窗口)强制踢出

正常启动 MySQL:/etc/init.d/mysql start   (service mysqld start)


清除密码、重置用户的文章:

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.


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:51203次
    • 积分:1070
    • 等级:
    • 排名:千里之外
    • 原创:51篇
    • 转载:49篇
    • 译文:0篇
    • 评论:6条
    文章分类
    最新评论