濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > MySQL root密碼的重置方法

MySQL root密碼的重置方法

熱門標(biāo)簽:呂梁外呼系統(tǒng) 400電話辦理服務(wù)價(jià)格最實(shí)惠 html地圖標(biāo)注并導(dǎo)航 南太平洋地圖標(biāo)注 大豐地圖標(biāo)注app 催天下外呼系統(tǒng) 北京金倫外呼系統(tǒng) 武漢電銷機(jī)器人電話 400電話變更申請(qǐng)

對(duì)于DBA來(lái)說(shuō),丟失超管用戶root的密碼是致命的,

可以通過(guò)添加--ship-grant-tables參數(shù)來(lái)跳過(guò)權(quán)限表。

1、忘記root密碼,進(jìn)不去數(shù)據(jù)庫(kù):

這個(gè)時(shí)候需要強(qiáng)制停庫(kù),先查看MySQL進(jìn)程號(hào)

Kill掉MySQL進(jìn)程,命令如下:

Kill完可以再查看是否還有進(jìn)程

[root@tse2 tmp]# kill -9 9840 1
[root@tse2 tmp]# ps -ef |grep mysql

建議停庫(kù)這種操作不要影響業(yè)務(wù)的情況下,停服操作的,還有最好這種密碼記錄好的,可以用keepass保存密碼軟件!

然后加跳過(guò)權(quán)限表參數(shù),重啟數(shù)據(jù)庫(kù)。這樣即使不輸入密碼,也可以進(jìn)入數(shù)據(jù)庫(kù)。

[root@tse2 bin]# mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables 
[1] 4854

直接輸入mysql不需要密碼即可進(jìn)入

給root用戶設(shè)置新的密碼并刷新權(quán)限,MySQL5.7之后,庫(kù)下的password字段用authentication_string字段代替。

(product)root@localhost:mysql.sock [(none)]> use mysql;
Database changed
(product)root@localhost:mysql.sock [mysql]> update user set authentication_string=password('123456') where user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 1

(product)root@localhost:mysql.sock [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

設(shè)置完成之后,重啟數(shù)據(jù)庫(kù)。注意重啟的時(shí)候不需要再加--skip-grant-tables參數(shù)了,正常啟動(dòng)服務(wù),輸入新的密碼可以正常進(jìn)入數(shù)據(jù)庫(kù)了。這邊重啟以后測(cè)試直接mysql沒(méi)有密碼是無(wú)法進(jìn)入的了。

[root@tse2 bin]# mysqld_safe --deaults-file=/etc/my.cnf 
[2] 6720
[root@tse2 bin]# 2020-01-16T02:55:45.223195Z mysqld_safe Logging to '/mysql/mysql3306/logs/error.log'.
2020-01-16T02:55:45.262302Z mysqld_safe A mysqld process already exists

[2]+  Exit 1                  mysqld_safe --deaults-file=/etc/my.cnf
[root@tse2 bin]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

這邊輸入密碼連接,即可正常進(jìn)入,是修改后的密碼123456

[root@tse2 bin]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.23-log MySQL Community Server (GPL)

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.

(product)root@localhost:mysql.sock [(none)]> use mysql
Database changed
(product)root@localhost:mysql.sock [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

以上就是MySQL root密碼的重置方法的詳細(xì)內(nèi)容,更多關(guān)于MySQL root密碼重置的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

您可能感興趣的文章:
  • MySQL8.0.23版本的root密碼重置最優(yōu)解法
  • Linux mysql-5.6如何實(shí)現(xiàn)重置root密碼
  • 重置mysql的root密碼最簡(jiǎn)單的方法
  • 解決重置Mysql root用戶賬號(hào)密碼問(wèn)題
  • mysql8重置root用戶密碼的完整步驟
  • mysql8.0.12如何重置root密碼
  • MySQL/MariaDB的Root密碼重置教程
  • Mac MySQL重置Root密碼的教程
  • windows下重置mysql的root密碼方法介紹
  • lnmp重置mysql數(shù)據(jù)庫(kù)root密碼的兩種方法
  • 詳解如何在Linux中重置MySQL或者M(jìn)ariaDB的root密碼
  • CentOS下重置MySQL的root密碼的教程

標(biāo)簽:迪慶 徐州 西寧 麗水 自貢 南充 龍巖 無(wú)錫

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MySQL root密碼的重置方法》,本文關(guān)鍵詞  MySQL,root,密碼,的,重置,方法,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《MySQL root密碼的重置方法》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于MySQL root密碼的重置方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    青海省| 新丰县| 福清市| 河池市| 洛扎县| 弥渡县| 白朗县| 泾川县| 皋兰县| 黑山县| 鄂尔多斯市| 万年县| 沭阳县| 清徐县| 岫岩| 浙江省| 三都| 绥宁县| 阿图什市| 栖霞市| 招远市| 梅州市| 西昌市| 玉门市| 康乐县| 无极县| 镇原县| 永登县| 南开区| 遂昌县| 盐边县| 济阳县| 新野县| 定远县| 景德镇市| 台山市| 邢台市| 永昌县| 多伦县| 莱州市| 电白县|