zoukankan      html  css  js  c++  java
  • 忘记 mysql 密码怎么办

    code

    [root@xxx ~]# vi /etc/my.cnf

    在[mysqld]中添加

    skip-grant-tables

    例如:

    [mysqld]
    skip-grant-tables
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock

    修改密码

    [root@xxx ~]# mysql -V
    mysql Ver 14.14 Distrib 5.7.32, for Linux (x86_64) using EditLine wrapper
    [root@xxx ~]# whereis mysql
    mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
    [root@xxx ~]# ps -ef|grep mysql
    mysql 1582 1 0 2020 ? 00:19:28 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
    root 14597 126576 0 19:35 pts/2 00:00:00 grep --color=auto mysql
    [root@xxx ~]# kill -9 1582
    [root@xxx ~]# 
    [root@xxx ~]# /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
    2021-01-08T11:36:11.650443Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2021-01-08T11:36:11.652252Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.32) starting as process 14688 ...
    2021-01-08T11:36:11.654799Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
    
    2021-01-08T11:36:11.654839Z 0 [ERROR] Aborting
    
    2021-01-08T11:36:11.654888Z 0 [Note] Binlog end
    2021-01-08T11:36:11.654946Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
    
    Initialization of mysqld failed: 0
    [root@xxx ~]# ps -ef|grep mysql
    mysql 14656 1 3 19:36 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
    root 14705 126576 0 19:36 pts/2 00:00:00 grep --color=auto mysql
    [root@xxx ~]# 
    [root@xxx ~]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.32 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> update user set authentication_string=password('123456') where user='root';
    ERROR 1046 (3D000): No database selected
    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('123456') where user='root';
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 1
    
    mysql> flush privileges;
    mysql> exit
    Bye
    [root@xxx ~]#



  • 相关阅读:
    xps坐标计算
    xps文档
    xps坐标提取
    javascript
    python 类的继承
    PHP parse_url函数示例
    PHP 二维数组按照指定键排序(正序或倒叙均可)
    PHP substr()函数参数解释 通俗易懂
    PHP四大经典排序算法源码
    X友 NC 远程命令执行
  • 原文地址:https://www.cnblogs.com/sea-stream/p/14253464.html
Copyright © 2011-2022 走看看