mysql忘記密碼找回的方法


mysql忘記密碼找回的方法:
在找回之前需要對 --skip-networking 參數進行了解
--skip-grant-tables: 關閉mysql驗證模塊

同時還需要關閉遠程連接(避免他人連接修改)
--skip-networking : 關閉TCP/IP連接

知道以上兩個參數后 現在可以進行找回密碼:
使用 mysqld_safe 啟動mysql

mysqld_safe --skip-grant-tables --skip-networking &

啟動完成后 輸入 mysql 即可無密碼登錄

直接插入新的賬號密碼:

INSERT INTO mysql.user VALUES 
('localhost',
'root',
PASSWORD('123'),
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',
0,0,0,0,'mysql_native_password','','N');

創建成功后,查詢創建的用戶情況:

mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)

驗證結果:

[root@db01 ~]# mysql -uroot -p123
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 1
Server version: 5.6.38 Source distribution

Copyright (c) 2000, 2017, 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.

重新啟動數據庫 改為正常模式(不再使用--skip-grant-tables --skip-networking)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM