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>
    
    修改完成
  • 相关阅读:
    使用PDO连接数据库
    ES6 promise
    弹框小三角
    封装弹窗功能
    css3 省略号
    使mac支持NTFS读写问题
    Vue 打包 build 前需要修改哪些配置和路径
    eslint配置大全
    在elementUI中使用 el-autocomplete 实现远程搜索的下拉框
    element-UI table自定义表头
  • 原文地址:https://www.cnblogs.com/Alex-Zeng/p/5508766.html
Copyright © 2011-2022 走看看