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> 
    
    
  • 相关阅读:
    switch-case的用法
    关于string
    串的顺序存储和链式存储
    【APIO2009T1】采油区域-分类讨论+动态规划
    【APIO2009T1】采油区域-分类讨论+动态规划
    【BashuOJ2963】数字游戏-DFS+剪枝
    【BashuOJ2963】数字游戏-DFS+剪枝
    【POJ3177】Redundant Paths-边双连通分量+缩点
    【POJ3177】Redundant Paths-边双连通分量+缩点
    【POJ2942】Knights of the Round Table-点双连通分量+判断奇环
  • 原文地址:https://www.cnblogs.com/lailaoban/p/14718117.html
Copyright © 2011-2022 走看看