由于种种原因,Mysql root用户的密码可能被恶意篡改,这个时候就需要对Mysql进行密码恢复了。大致步骤如下:

  1、修改MySQL的登录设置:
    # vi /etc/my.cnf
    在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi。
  2、重新启动mysqld
    # /etc/init.d/mysqld restart  ( service mysqld restart )
  3、登录并修改MySQL的root密码
    mysql> USE mysql ;
    mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
    mysql> flush privileges ;
    mysql> quit
  4、将MySQL的登录设置修改回来
    # vi /etc/my.cnf
    将刚才在[mysqld]的段中加上的skip-grant-tables删除,保存并且退出vi。
  5、重新启动mysqld
    # /etc/init.d/mysqld restart   ( service mysqld restart )

相关文章:

  • 2021-08-15
  • 2022-01-18
  • 2021-04-14
  • 2021-05-02
  • 2021-07-25
  • 2022-02-28
  • 2021-10-04
  • 2022-12-23
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2021-11-28
  • 2021-06-21
  • 2021-11-05
  • 2022-02-19
  • 2022-12-23
相关资源
相似解决方案