Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误

1、首先关闭mysql服务

sudo service mysql stop

2、在/ect/my.cnf 配置文件中,添加一行代码skip_grant_tables即可,然后保存退出

 3、启动mysql服务

sudo service mysql start

4、直接输入mysql -uroot -p ,然后不用输入密码,直接敲击回车即可

5、最后重置你的密码

update mysql.user set authentication_string=password('root')   where user='root' and host='localhost';

posted @ 2023-02-10 14:50  JamieChyi  阅读(86)  评论(0)    收藏  举报  来源