当前位置:Gxlcms > 数据库问题 > 重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

时间:2021-07-01 10:21:17 帮助过:11人阅读

/etc/my.cnf is ignored // 该文件权限过高
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)// 密码错误

解决方法:

1. chmod 644 /etc/my.cnf // 修改/etc/my.cnf权限 
2. grep ‘password‘ /var/log/mysqld.log |head -n 1 // 找临时密码,如果找不到请看3
3. 3如果不行请看4
1.删除原来安装过的mysql残留的数据(这一步非常重要,问题就出在这)
  rm -rf /var/lib/mysql
2.重启mysqld服务
  systemctl restart mysqld
3.再去找临时密码
  grep temporary password /var/log/mysqld.log
4. #重置密码
  (1) 在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,保存文档并退出 //vim /etc/my.cnf
  (2) 重启mysql  // service mysql restart
  
  (3)mysql // 免密登陆  

  (4)use mysql;
    update mysql.user set authentication_string=password(‘你的新密码‘) where user=‘root‘; // 注意password()是个函数,负责加密密码,不要删除
    flush privileges;
  
  (5)删除/etc/my.cnf中的skip-grant-tables
  (6)重启mysql服务

 

重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

标签:密码验证   mysq   col   var   权限   rest   密码   sql   vim   

人气教程排行