zoukankan      html  css  js  c++  java
  • MySQL5.7 忘记root密码,怎么破?

    MySQL5.7 忘记root密码,怎么破?

    关服

    # kill $mysql_pid
    

    免密启动

    # /usr/local/mysql57/bin/mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
    [1] 16688
    2017-12-08T10:32:24.764472Z mysqld_safe Logging to '/data/database/mysql/host-30-0-0-196.err'.
    2017-12-08T10:32:24.901997Z mysqld_safe Starting mysqld daemon with databases from /data/database/mysql
    

    改密码呀

    # /usr/local/mysql57/bin/mysql -S /tmp/mysql.sock 
    mysql> update mysql.user set authentication_string=password('4a68a3c809c38e31') where user='root' ; 
    Query OK, 1 row affected, 1 warning (0.01 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    mysql> quit
    Bye
    

    重启

    # /usr/local/mysql57/bin/mysqladmin -S /tmp/mysql3308.sock shutdown  
    2017-12-08T10:33:02.360399Z mysqld_safe mysqld from pid file /data/database/mysql/host-30-0-0-196.pid ended
    [1]+  Done                  阿/usr/local/mysql57/bin/mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables
    
    # /usr/local/mysql57/bin/mysqld_safe --defaults-file=/etc/my.cnf
    

    还得再改一次

    You must reset your password using ALTER USER statement before executing this statement.
    mysql> alter user root@localhost identified by '4a68a3c809c38e31';
    Query OK, 0 rows affected (0.01 sec)
    

    可以了

  • 相关阅读:
    利用clear清除浮动的一些问题
    配置SpringBoot方便的切换jar和war
    java并发实战:连接池实现
    canvas绘制圆角头像
    对象的合并及拷贝
    JS数组去重
    浏览器端用JS实现创建和下载图片
    超过固定宽度(或行数)显示...(或省略)
    ssh实现免密登录
    Mac 日常使用问题收集
  • 原文地址:https://www.cnblogs.com/wshenjin/p/8006762.html
Copyright © 2011-2022 走看看