成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

MySQL數(shù)據(jù)庫(kù)密碼忘記了,怎么辦?

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

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

登錄MySQL,密碼輸入錯(cuò)誤

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

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

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

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

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

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

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

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


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

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

/*  此時(shí)可以直接登錄數(shù)據(jù)庫(kù) 無(wú)需輸入密碼 */
[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命令修改密碼,只能通過(guò)更新數(shù)據(jù)庫(kù)表的方式

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中密碼存儲(chǔ)在password中,MySQL8.0中加密方式有變更等,處理時(shí)需要根據(jù)版本來(lái)相應(yīng)修改腳本處理。

4 . 將配置文件還原

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

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

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

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

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

啟動(dòng)后,即可使用重置后的密碼登錄

[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ù)庫(kù)密碼一定要妥善保管,雖然可以找回,但需要重啟,影響數(shù)據(jù)庫(kù)可用性。

責(zé)任編輯:華軒 來(lái)源: 今日頭條
相關(guān)推薦

2010-04-20 08:56:53

2011-07-27 11:19:48

2021-01-30 09:50:54

MySQL密碼服務(wù)器

2009-11-30 13:27:21

2025-01-14 00:00:10

Mysql登陸數(shù)據(jù)庫(kù)

2021-01-04 09:40:48

Linux運(yùn)維Linux系統(tǒng)

2020-10-20 08:01:30

MySQL密碼Windows

2010-06-09 08:39:34

2010-06-07 17:45:06

MySQL數(shù)據(jù)庫(kù)密碼

2009-02-24 09:36:00

路由器密碼恢復(fù)CISCO 2600

2013-01-21 09:32:10

2010-05-27 18:24:09

MySQL數(shù)據(jù)庫(kù)密碼

2010-08-18 15:24:14

路由器密碼

2013-07-15 09:51:04

2024-04-22 08:17:23

MySQL誤刪數(shù)據(jù)

2020-04-28 10:24:55

Wi-FiWindows密碼

2015-03-19 09:15:20

2016-12-15 12:24:03

Oracle數(shù)據(jù)庫(kù)密碼

2021-01-15 13:31:25

加密貨幣密碼比特幣

2010-08-04 14:38:34

路由器密碼
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: a级免费视频 | 丁香五月网久久综合 | caoporn免费在线视频 | 亚洲一区二区三区四区五区午夜 | 日本五月婷婷 | 国产精品久久久久婷婷二区次 | 国产综合视频 | 日本高清视频在线播放 | 99久久精品国产一区二区三区 | 国产精品毛片一区二区三区 | 亚洲精品久久久久久宅男 | 亚洲性视频 | 日韩免费一区二区 | 国产91av视频在线观看 | 波多野结衣在线观看一区二区三区 | 亚洲一区二区精品视频 | 国产免费一区二区 | www.久久| 91在线色视频 | 91免费版在线观看 | 欧美日韩高清免费 | 久久一区二区三区四区 | 91视频久久| 中文字幕在线一区 | 九九综合 | 久久一区二区精品 | 另类视频在线 | 国产成人免费视频网站高清观看视频 | 免费成人毛片 | 亚洲精品久久久 | 免费观看成人鲁鲁鲁鲁鲁视频 | 久久精品com| 波多野结衣在线观看一区二区三区 | 久久久激情视频 | 神马福利| 国产精品久久国产精品99 | 精品国产视频在线观看 | 久久久久久综合 | 999久久精品 | 欧美成人二区 | 91精品国产欧美一区二区 |