本文主要給大家簡(jiǎn)單講講mysql5.6密碼忘記了該如何恢復(fù),相關(guān)專業(yè)術(shù)語(yǔ)大家可以上網(wǎng)查查或者找一些相關(guān)書(shū)籍補(bǔ)充一下,這里就不涉獵了,我們就直奔主題吧,希望mysql5.6密碼忘記了該如何恢復(fù)這篇文章可以給大家?guī)?lái)一些實(shí)際幫助。

實(shí)驗(yàn)環(huán)境:
1、centos7.3
2、mysql5.6.35
實(shí)驗(yàn)描述:
原mysql僅root賬號(hào)可以登錄且有密碼保護(hù),現(xiàn)在密碼已經(jīng)忘記無(wú)法找回。今天的目標(biāo)就是通過(guò)破解,重置mysql的root密碼。
實(shí)驗(yàn)進(jìn)行時(shí):
1、開(kāi)始之前確定mysql不用密碼已經(jīng)不能登錄了
[root@c73 mysql]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@c73 mysql]# [root@c73 ~]# mysql -u root -p654321 //用654321這個(gè)密碼也進(jìn)不了。 Warning: Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
2、跳過(guò)授權(quán)進(jìn)入mysql
[root@c73 mysql]# systemctl stop mysql //停止mysql //由于我本身使用的是root賬號(hào),mysql運(yùn)行需要mysql賬號(hào)所以,增加了--user=mysql, //這里主要是使用--skip-grant-tables參數(shù)跳過(guò)授權(quán)表 [root@c73 mysql]# mysqld --user=mysql --skip-grant-tables & [1] 6022 [root@c73 mysql]# 2017-04-11 09:36:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-04-11 09:36:41 0 [Note] mysqld (mysqld 5.6.35) starting as process 6022 ... 2017-04-11 09:36:41 6022 [Note] Plugin 'FEDERATED' is disabled. 2017-04-11 09:36:41 6022 [Note] InnoDB: Using atomics to ref count buffer pool pages 2017-04-11 09:36:41 6022 [Note] InnoDB: The InnoDB memory heap is disabled 2017-04-11 09:36:41 6022 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-04-11 09:36:41 6022 [Note] InnoDB: Memory barrier is not used 2017-04-11 09:36:41 6022 [Note] InnoDB: Compressed tables use zlib 1.2.3 2017-04-11 09:36:41 6022 [Note] InnoDB: Using Linux native AIO 2017-04-11 09:36:41 6022 [Note] InnoDB: Using CPU crc32 instructions 2017-04-11 09:36:41 6022 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2017-04-11 09:36:41 6022 [Note] InnoDB: Completed initialization of buffer pool 2017-04-11 09:36:41 6022 [Note] InnoDB: Highest supported file format is Barracuda. 2017-04-11 09:36:41 6022 [Note] InnoDB: 128 rollback segment(s) are active. 2017-04-11 09:36:41 6022 [Note] InnoDB: Waiting for purge to start 2017-04-11 09:36:42 6022 [Note] InnoDB: 5.6.35 started; log sequence number 1626007 2017-04-11 09:36:42 6022 [Note] Server hostname (bind-address): '*'; port: 3306 2017-04-11 09:36:42 6022 [Note] IPv6 is available. 2017-04-11 09:36:42 6022 [Note] - '::' resolves to '::'; 2017-04-11 09:36:42 6022 [Note] Server socket created on IP: '::'. 2017-04-11 09:36:42 6022 [Note] mysqld: ready for connections. Version: '5.6.35' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) [root@c73 mysql]# netstat -lnpt|grep 3306 //確定服務(wù)開(kāi)啟成功 tcp6 0 0 :::3306 :::* LISTEN 6022/mysqld [root@c73 mysql]# mysql //無(wú)密碼進(jìn)入mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.35 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> //成功進(jìn)入^_^
3、修改root密碼
mysql> set password for 'root'@'localhost' = password('654321');
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
// 在--skip-grant-tables模式下,以上修改密碼的方法是行不通了。
// 所以我們直接修改用戶表來(lái)更新密碼。
mysql> update mysql.user set password=password("654321") where user='root';
Query OK, 4 rows affected (0.00 sec) #更新成功了4條root用戶的密碼
Rows matched: 4  Changed: 4  Warnings: 0
// 最后別忘了刷新
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit //退出
Bye4、這時(shí)候我們?cè)賮?lái)用新密碼測(cè)試看看能不能進(jìn)入吧
[root@c73 ~]# ps aux|grep mysql mysql 6022 0.0 11.6 1038816 452312 pts/0 Sl 09:36 0:00 mysqld --user=mysql --skip-grant-tables root 6113 0.0 0.0 112664 968 pts/1 R+ 10:00 0:00 grep --color=auto mysql [root@c73 ~]# kill -9 6022 //結(jié)束掉原來(lái)的mysql服務(wù) [root@c73 ~]# systemctl start mysql 以正常模式開(kāi)啟mysql服務(wù) [root@c73 ~]# ps aux|grep mysql mysql 6132 0.0 0.0 113252 1588 ? Ss 10:00 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr mysql 6310 1.8 2.8 698944 110984 ? Sl 10:00 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock root 6337 0.0 0.0 112664 972 pts/1 R+ 10:01 0:00 grep --color=auto mysql [root@c73 ~]# mysql #測(cè)試不用密碼無(wú)法進(jìn)入 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@c73 ~]# mysql -u root -p654321 #測(cè)試使用新密碼進(jìn)入成功^_^ 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.6.35 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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>
實(shí)驗(yàn)總結(jié):
密碼盡可能的保存好吧,如果是線上24小時(shí)不間斷的業(yè)務(wù),出現(xiàn)這種情況必須重啟服務(wù)來(lái)處理,或多或少都會(huì)帶來(lái)一些不必要的麻煩。
mysql5.6密碼忘記了該如何恢復(fù)就先給大家講到這里,對(duì)于其它相關(guān)問(wèn)題大家想要了解的可以持續(xù)關(guān)注我們的行業(yè)資訊。我們的板塊內(nèi)容每天都會(huì)捕捉一些行業(yè)新聞及專業(yè)知識(shí)分享給大家的。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
                當(dāng)前名稱:mysql5.6密碼忘記了該如何恢復(fù)-創(chuàng)新互聯(lián)
                
                網(wǎng)頁(yè)路徑:http://www.chinadenli.net/article12/dosgdc.html
            
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、軟件開(kāi)發(fā)、定制開(kāi)發(fā)、做網(wǎng)站、網(wǎng)站排名、App開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
