zoukankan      html  css  js  c++  java
  • MySQL 5.7.11 重置root密码

    1.修改/etc/my.conf,添加参数skip-grant-tables
    2.重启mysql
    service mysqld stop
    service mysqld start
    3.用root 直接登录
    [root@bogon ~]# mysql -uroot
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 4
    Server version: 5.7.11 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>
    4.修改密码
    mysql> alter user 'root'@'localhost' identified by 'newpassword';
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
    mysql>
    这种方式不好使,换一种方式:
    
    mysql> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> update user set authentication_string=PASSWORD('newpassword') where User='root';
    Query OK, 1 row affected, 1 warning (0.07 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    mysql>
    5.将/ect/my.conf 修改回来,重启mysql 测试新密码
    [root@bogon ~]# service mysqld stop
    Stopping mysqld:                                           [  OK  ]
    [root@bogon ~]# service mysqld start
    Starting mysqld:                                           [  OK  ]
    [root@bogon ~]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    Server version: 5.7.11 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>
    
    修改完成
  • 相关阅读:
    [SUCTF 2019]EasySQL 1【BUUCFT】【SQL注入】
    [HCTF 2018]WarmUp 1【BUUCFT】【代码审计】
    [强网杯 2019]随便注 1 【BUUCFT】【SQL注入】
    网站如何做好防护
    【单片机】换行、回车
    【Win32】VC6 Visual C/C++ 6.0 修改程序图标
    【Win32】通过多线程自动关闭对话框的方法
    微服务demo
    Mac安装redis
    python---rsa加密根据指数和模生成加密参数模板
  • 原文地址:https://www.cnblogs.com/Alex-Zeng/p/5508766.html
Copyright © 2011-2022 走看看