MySQL5.7忘记root密码如何重置

  1. 修改配置文件并重启:

    [root@localhost ~]# vi /etc/my.cnf
    

    在[mysqld]添加一行

    skip-grant-tables
    

    重启服务

    [root@localhost ~]# systemctl restart mysqld
    
  2. 进入mysql修改root密码:

    [root@localhost ~]# mysql -uroot
    mysql> update mysql.user set authentication_string=password('newPassWord!123') where user='root' and host='localhost';
    

    * mysql5.7密码要求大小写字母数字特殊符号

  3. 退出mysql,重新修改/etc/my.cnf,删掉skip-grant-tables

  4. 重启服务

    [root@localhost ~]# systemctl restart mysqld
    
  5. 使用新密码登录:

    [root@localhost ~]# mysql -uroot -p
    
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容