(一).通过命令修改,具体如下:
a、停止MySQL服务
执行:/etc/init.d/mysql stop
b、跳过验证启动MySQL
/usr/local/mysql/bin/mysqld_safe –skip-grant-tables >/dev/null 2>&1 &
然后:
mysql mysql -uroot //登陆
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
mysql> FLUSH PRIVILEGES;
mysql> quit
然后重新启动mysql
/etc/init.d/mysql start
(二).在/tmp/my.cnf的[mysqld]下加入skip-grant-tables ;
重启mysql服务 etc/init.d/mysql restart
mysql mysql -uroot //登陆
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
mysql> FLUSH PRIVILEGES;
mysql> quit;
去掉在/tmp/my.cnf的[mysqld]下加入skip-grant-tables ;
然后重新启动mysql
/etc/init.d/mysql start
参考链接:
https://blog.youkuaiyun.com/sinat_32829963/article/details/70196355
https://blog.youkuaiyun.com/wodeai1235/article/details/76836371
重置MySQL root密码
本文介绍两种重置MySQL root密码的方法:一是通过命令修改,包括停止MySQL服务、跳过验证启动MySQL并更新密码等步骤;二是修改配置文件,通过添加skip-grant-tables选项临时禁用权限表检查。
2万+

被折叠的 条评论
为什么被折叠?



