Mysql登录报错 “Access denied for user 'root'@'localhost' (using password: YES)”

1.环境

CentOS 7.6
Mysql 5.7

2.问题

3.解决方案

1. 关闭Mysql服务

service mysqld stop

2. 使用命令跳过输入密码验证过程

mysqld_safe --skip-grant-tables &

#--skip-grant-tables:跳过授权表,通过此参数来跳过输入密码,
# & 表示设置此进程为后台进程

3. 进入Mysql数据库,通过sql语句修改密码

  use mysql;
  update user set authentication_string=password("admin") where user = 'root';

  --刷新权限
  flush privileges;

4. 重启Mysql服务,使用新密码登录

 service mysqld restart

猜你喜欢

转载自www.cnblogs.com/wuning/p/11737432.html