最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL5.7及8.0版本數(shù)據(jù)庫的root密碼遺忘的解決

注:MySQL5.7破解root密碼,跳過密碼認(rèn)證登錄到數(shù)據(jù)庫,直接修改表中的密碼即可,但是MySQL 8.0則不可以這樣修改root密碼,需要跳過密碼認(rèn)證登錄到數(shù)據(jù)庫后,先將root密碼設(shè)置為空,然后才可以登錄到數(shù)據(jù)庫,修改root密碼。

阿拉爾網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,阿拉爾網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為阿拉爾近1000家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的阿拉爾做網(wǎng)站的公司定做!

1、遺忘MySQL 5.7數(shù)據(jù)庫的root密碼解決辦法

方法1(推薦):
[root@mysql ~]# systemctl stop mysqld        #停止MySQL服務(wù)
[root@mysql ~]# mysqld --user=root --skip-grant-tables    #使用mysqld指令啟動mysql服務(wù),跳過授權(quán)表
#上述命令執(zhí)行后,會一直占用當(dāng)前終端,需要再開啟一個終端,
#也不要想著放到后臺運行了,放到后臺3306端口不會監(jiān)聽的
[root@mysql ~]# ss -anpt | grep 3306     #再開啟一個終端,確定端口在監(jiān)聽
LISTEN     0      80          :::3306                    :::*                   users:(("mysqld",pid=8282,fd=33))
[root@mysql ~]# mysql -uroot           #直接使用root用戶登錄,無需密碼
mysql> update mysql.user set authentication_string=password('1234') 
    -> where User='root' and Host='localhost';
        #更改root密碼為“1234”
mysql> flush privileges;          #刷新權(quán)限
[root@mysql ~]# kill 8282         #將之前mysqld啟動時占用的終端進(jìn)程號kill掉,切忌不要使用-9選項
[root@mysql ~]# systemctl start mysqld      #啟動MySQL服務(wù),使用新密碼登錄即可

如果上面的過程中,使用kill -9來結(jié)束mysqld占用的終端,那么再次啟動可能會報錯,sock文件被鎖定,此時,需要將你mysql的sock文件刪除掉,我這里的sock文件在/tmp下,分別時mysql.sock.lock和mysql.sock這兩個文件,刪除后再次啟動MySQL即可。

方法2:
[root@mysql01 ~]# mysql --version        #確定MySQL版本
mysql  Ver 14.14 Distrib 5.7.28, for linux-glibc2.12 (x86_64) using  EditLine wrapper
[root@mysql01 ~]# vim /etc/my.cnf         #編輯主配置文件
[mysqld]      #在mysqld這行下寫入下面內(nèi)容
skip-grant-tables
            .................#省略部分內(nèi)容
[root@mysql01 ~]# systemctl restart mysqld      #重啟MySQL服務(wù),使配置文件生效
[root@mysql01 ~]# mysql -uroot           #跳過密碼驗證,直接登錄數(shù)據(jù)庫
#修改root密碼為pwd@123,并刷新權(quán)限
mysql> use mysql;
mysql> update user set authentication_string = passwoord('pwd@123') where user = 'root';
mysql> flush privileges;     #刷新權(quán)限
mysql> exit
#配置密碼驗證,使用新密碼登錄
[root@mysql01 ~]# vim /etc/my.cnf         #編輯主配置文件
[mysqld] 
skip-grant-tables            #刪除此行
[root@mysql01 ~]# systemctl restart mysqld          #重啟使更改生效
#使用新密碼即可成功登錄
[root@mysql01 ~]# mysql -uroot -ppwd@123       

2、遺忘MySQL 8.0數(shù)據(jù)庫的root密碼解決辦法

[root@mysql01 ~]# mysql --version        #查看MySQL版本
mysql  Ver 8.0.18 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
[root@mysql01 ~]# vim /etc/my.cnf         #編輯主配置文件
[mysqld]      #在mysqld這行下寫入下面內(nèi)容
skip-grant-tables
            .................#省略部分內(nèi)容
[root@mysql01 ~]# systemctl restart mysqld      #重啟MySQL服務(wù),使配置文件生效
[root@mysql01 ~]# mysql -uroot           #跳過密碼驗證,直接登錄數(shù)據(jù)庫
#將root密碼設(shè)置為空
mysql> use mysql
mysql> update user set authentication_string='' where user = 'root';
mysql> flush privileges;
mysql> exit
#開啟密碼驗證并重新登錄數(shù)據(jù)庫
[root@mysql01 ~]# vim /etc/my.cnf         #編輯主配置文件
[mysqld] 
skip-grant-tables            #刪除此行
[root@mysql01 ~]# systemctl restart mysqld          #重啟使更改生效
[root@mysql01 ~]# mysql -uroot            #直接登錄數(shù)據(jù)庫
mysql> alter user root@localhost identified by 'pwd@111';
mysql> flush privileges;
mysql> exit
#使用新密碼進(jìn)行登錄測試
[root@mysql01 ~]# mysql -uroot -ppwd@111

———————— 本文至此結(jié)束,感謝閱讀 ————————


本文標(biāo)題:MySQL5.7及8.0版本數(shù)據(jù)庫的root密碼遺忘的解決
分享網(wǎng)址:http://fisionsoft.com.cn/article/jhgcee.html