Access denied for user ‘root‘@‘localhost‘ (using password: NO)

2022-07-31,,,,

1.首先结束mysql进程,利用ps aux | grep mysql 得到进程ID号
2.kill ID号,结束进程
3.mysqld --skip-grant-tables​
mysqld_safe --user=mysql --skip-grant-tables --skip-networking&
4.然后,再开一个终端,输入mysql -u root mysql
5.进去后,执行

UPDATE user SET Password=PASSWORD('my_password') where USER='root';
FLUSH PRIVILEGES;

6.退出,重启mysql,然后你再运行mysql -u root -p输入你的密码,应该就OK了

本文地址:https://blog.csdn.net/weixin_45706762/article/details/107674350

《Access denied for user ‘root‘@‘localhost‘ (using password: NO).doc》

下载本文的Word格式文档,以方便收藏与打印。