Mysql5.7 CentOS7 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

环境 Mysql5.7.24  CenOS 7.3.16

解决方案:

第一步:

#systemctl stop mysqld.service

关闭mysql服务

第二步:

#vim /etc/my.cnf

打开mysql配置文件

第三步:

最后面加入  skip-grant-tables

第四步:

#systemctl start mysqld.service

打开MySQL服务

第四步:

mysq -hlocal -uroot

use mysql

update user set authentication_string='NewPassword' where user='root';

免密登录mysql

选择mysql数据库

更新root用户密码

第五步:

删除第二步的语句

-------------------------------------------------------------------------华丽的分割线

附录:mysql重要配置文件    etc/my.cnf

查看linux版本   uname  -a  或 cat /etc/redhat-release

查看mysql版本 select version()

猜你喜欢

转载自www.cnblogs.com/liu-cheng-biao/p/10303178.html
今日推荐