linux下mysql登陆报错Access denied for user ‘root‘@‘localhost‘
·
linux下mysql登陆报错Access denied for user ‘root’@‘localhost’
vim /etc/my.cnf
#在打开文档中找到[mysqld]并在下面添加一行skip-grant-tables并保存退出
[mysqld]
skip-grant-tables
#重启服务使配置文件更改生效
systemctl restart mysqld;
# 直接输入mysql进入数据库,输入以下几行命令,123456可以替换成你想要的密码,前面的东西别删
# 前面的authentication_string字段根据mysql版本不一致可能有出入有的版本好像是passsword,建议desc user;看一下数据表里是什么字段
mysql
use mysql;
update user set authentication_string=password('123456') where user="root";
flush privileges;
quit;
vim /etc/my.cnf
#注释或删除skip-grant-tables并保存退出
[mysqld]
# skip-grant-tables
#重启服务使配置文件更改生效
systemctl restart mysqld;
mysql -uroot -p
123456
更多推荐
所有评论(0)