zoukankan      html  css  js  c++  java
  • mysql 忘记本地密码

    MySQL本地管理员忘记密码

    解决办法

    1.重启数据库到无验证模式

    [root@oldboy ~]# vim /etc/my.cnf 
    [root@oldboy ~]# cat /etc/my.cnf 
    [mysqld]
    user=mysql
    basedir=/usr/local/mysql
    datadir=/data/3306/data
    port=3306
    socket=/tmp/mysql.sock
    skip-grant-tables
    skip-networking
    [client]
    socket=/tmp/mysql.sock
    [root@oldboy ~]# systemctl restart mysqld.service 
    

    2.修改登录密码

    [root@oldboy ~]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 7
    Server version: 8.0.20 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2020, 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> 
    mysql> flush privileges;   #重新加载授权表
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> alter user root@'localhost' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    [root@oldboy ~]# vim /etc/my.cnf 
    [root@oldboy ~]# cat /etc/my.cnf 
    [mysqld]
    user=mysql
    basedir=/usr/local/mysql
    datadir=/data/3306/data
    port=3306
    socket=/tmp/mysql.sock
    [client]
    socket=/tmp/mysql.sock
    

    3.正常启动数据库

    [root@oldboy ~]# systemctl restart mysqld.service 
    [root@oldboy ~]# mysql -uroot -p123456
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.20 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2020, 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> 
    
    
  • 相关阅读:
    pku 1330 LCA
    最近公共祖先(LCA)的Tarjan算法
    字典数模板
    字典树
    RMQ问题ST算法与模板
    RMQ(Range Minimum/Maximum Query)问题:
    罗穗骞的dc3和倍增法
    多重背包问题
    tarjan LCA 算法
    终极工程师的造诣 – 不迷信高科技的乔布斯给我们的启示
  • 原文地址:https://www.cnblogs.com/lailaoban/p/14718117.html
Copyright © 2011-2022 走看看