Centos7 mysq登录提示:Access denied for user 'root'@'localhost'

114 阅读1分钟

1.停止mysql

systemctl stop mysqld.service

2.修改配置文件无密码登录

配置文件地址 /etc/my.cnf

在文件最后一行增加如下内容

skip-grant-tables

3.保存,重新启动mysql

systemctl start mysqld.service

4.再次登录mysql

mysql -u root

这样我们就可以登录成功了