日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL數(shù)據(jù)庫密碼忘記了,怎么辦?

MySQL數(shù)據(jù)庫密碼忘記了且沒有其他可以修改賬號密碼的賬戶時怎么辦呢?

公司主營業(yè)務(wù):網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出廬山免費(fèi)做網(wǎng)站回饋大家。

登錄MySQL,密碼輸入錯誤

/* 密碼錯誤,報如下錯誤 */
[root@TESTDB ~]# mysql -uroot -p -P3306
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

如果忘記密碼,對于MySQL而言處理起來也相對比較簡單。但需要修改配置,重啟數(shù)據(jù)庫。可以按照如下步驟處理。

1. 修改數(shù)據(jù)庫配置文件

vim  /etc/my.cnf
-- 添加如下參數(shù)
skip_grant_tables

2. 重啟數(shù)據(jù)庫

如果部署了服務(wù) 可以重啟數(shù)據(jù)庫服務(wù)重啟,如果沒有部署,需要?dú)⒌魯?shù)據(jù)庫進(jìn)程,在重新啟動數(shù)據(jù)庫。

/*  重啟數(shù)據(jù)庫服務(wù) */
/etc/init.d/mysqld restart

ps -ef|grep mysql /* 查出MySQL 的進(jìn)程號,下一步中使用 */


kill 30516 29246 /* 不建議使用 kill -9 */

3. 登錄數(shù)據(jù)庫修改密碼

/*  此時可以直接登錄數(shù)據(jù)庫 無需輸入密碼 */
[root@TESTDB ~]# mysql -uroot -P3306
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.23-24-log Percona Server (GPL), Release 24, Revision 57a9574


Copyright (c) 2009-2018 Percona LLC and/or its affiliates
Copyright (c) 2000, 2018, 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>
再修改密碼
/* MySQL5.7 中修改密碼 */
mysql> update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';
Query OK, 0 rows affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 0 Warnings: 1


mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

注:

a) 不可以使用set password命令修改密碼,只能通過更新數(shù)據(jù)庫表的方式

mysql> set password=password('123456');
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

b) 使用update表mysql.user的方式需要flush privileges生效

c) 不同的版本mysql.user的字段以及密碼加密方式不同,例如MySQL5.6中密碼存儲在password中,MySQL8.0中加密方式有變更等,處理時需要根據(jù)版本來相應(yīng)修改腳本處理。

4 . 將配置文件還原

去掉第1步中my.cnf配置文件中添加的skip_grant_tables參數(shù)

vim  /etc/my.cnf
#skip_grant_tables /* 注釋掉該參數(shù)*/

5. 重啟數(shù)據(jù)庫

Mysql5.7中可以直接在MySQL命令行中使用shutdown命令關(guān)閉數(shù)據(jù)庫,之后再啟動數(shù)據(jù)庫即可。

mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)

啟動后,即可使用重置后的密碼登錄

[root@TESTDB ~]# mysql -uroot    -P3306   -p'123456'
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 3
Server version: 5.7.23-24-log Percona Server (GPL), Release 24, Revision 57a9574


Copyright (c) 2009-2018 Percona LLC and/or its affiliates
Copyright (c) 2000, 2018, 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>

至此,密碼重置完畢。

TIPS: 生產(chǎn)環(huán)境的數(shù)據(jù)庫密碼一定要妥善保管,雖然可以找回,但需要重啟,影響數(shù)據(jù)庫可用性。


網(wǎng)站欄目:MySQL數(shù)據(jù)庫密碼忘記了,怎么辦?
文章起源:http://www.5511xx.com/article/djohjgs.html