首页>>帮助中心>>美国vps服务器中linux连接mysql输入正确密码报错的问题

美国vps服务器中linux连接mysql输入正确密码报错的问题

2023/5/28 683次
Linux连接Mysql输入正确密码的时候报错误: Access denied for user'root'@'localhost'(using password: YES)

如何解决:

     
  1.  

    先停掉服务: service mysqld stop  

     
  2.  
  3.  

    然后使用安全模式登录跳过密码验证:  

     

    mysqld_safe --user=mysql --skip-grant-tables --skip-networking&  

     

     
  1.  

    登录: mysql -uroot mysql  

     

    4.修改密码 :  

     

    mysql > update user set authentication_string = password('******') where user = 'root' and Host = 'localhost'  

     

    在password(‘’)在引号里面输入要修改的密码  

     

     

     

    5.刷新权限: mysql > flush privileges  

     

然后在尝试连接一下数据库: mysql /usr/local/mysql/bin/mysql -uroot -p