您好,欢迎来到九壹网。
搜索
您的当前位置:首页mysql5.7重置root密码

mysql5.7重置root密码

来源:九壹网

第一步:修改配置文件免密码登录mysql

vim /etc/my.cnf  
##在my.cnf的[mysqld]字段加入
skip-grant-tables

## 重启mysql服务
service mysqld restart

第二步:免密码登录mysql

mysql -u root 
##password直接回车

第三步: 给root重置密码为空

mysql>use mysql;
## mysql 5.7.9以后废弃了password字段,字段名修改为authentication_string
mysql>update user set authentication_string='' where user='root';
## 刷新数据库
mysql>flush privileges;

第四步: root重置密码
  退出mysql,删除/etc/my.cnf文件最后的 skip-grant-tables 重启mysql服务,使用root用户进行登录,因为上面设置了authentication_string为空,所以可以免密码登录。

alter user 'root'@'localhost' identified by '#新密码#';

功德,修改成功

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务