1、#vi  /etc/my.cnf

在[mysqld]下加入一行:skip-grant-tables

mysql忘记密码解决办法

2、#service mysql restart        //重启mysql

     #mysql  -uroot  -p              //不用输入密码直接回车进入mysql

 

3、mysql> update mysql.user set authentication_string=password('[email protected]') where user='root';      //修改临时密码

      mysql> quit

mysql忘记密码解决办法

 

4、#vi  /etc/my.cnf        

把新增的skip-grant-tables注释掉

mysql忘记密码解决办法

#service mysql restart      //重启mysql

# mysql -uroot [email protected]      //用临时密码进入mysql

mysql>  set password for 'root'@'localhost' =password('[email protected]');           //设置永久密码

mysql> grant all privileges on *.* to [email protected]"%" identified by '[email protected]' with grant option;      //设置允许mysql远程连接

mysql> flush privileges;

mysql> quit

#service mysql restart

 

相关文章:

  • 2021-12-27
  • 2021-12-06
  • 2021-11-11
  • 2021-05-29
  • 2021-12-01
  • 2021-09-25
猜你喜欢
  • 2021-11-28
  • 2021-11-28
  • 2021-04-21
  • 2021-04-25
  • 2021-08-10
  • 2021-12-23
  • 2021-08-09
相关资源
相似解决方案