小編給大家分享一下 5.7及8.0版本數據庫的root密碼遺忘怎么辦,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
注:MySQL5.7破解root密碼,跳過(guò)密碼認證登錄到數據庫,直接修改表中的密碼即可,但是MySQL 8.0則不可以這樣修改root密碼,需要跳過(guò)密碼認證登錄到數據庫后,先將root密碼設置為空,然后才可以登錄到數據庫,修改root密碼。
1、遺忘MySQL 5.7數據庫的root密碼解決辦法
[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這行下寫(xiě)入下面內容 skip-grant-tables .................#省略部分內容 [root@mysql01 ~]# systemctl restart mysqld #重啟MySQL服務(wù),使配置文件生效 [root@mysql01 ~]# mysql -uroot #跳過(guò)密碼驗證,直接登錄數據庫 #修改root密碼為pwd@123,并刷新權限 mysql> use mysql; mysql> update user set authentication_string = passwoord('pwd@123') where user = 'root'; mysql> flush privileges; #刷新權限 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數據庫的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這行下寫(xiě)入下面內容 skip-grant-tables .................#省略部分內容 [root@mysql01 ~]# systemctl restart mysqld #重啟MySQL服務(wù),使配置文件生效 [root@mysql01 ~]# mysql -uroot #跳過(guò)密碼驗證,直接登錄數據庫 #將root密碼設置為空 mysql> use mysql mysql> update user set authentication_string='' where user = 'root'; mysql> flush privileges; mysql> exit #開(kāi)啟密碼驗證并重新登錄數據庫 [root@mysql01 ~]# vim /etc/my.cnf #編輯主配置文件 [mysqld] skip-grant-tables #刪除此行 [root@mysql01 ~]# systemctl restart mysqld #重啟使更改生效 [root@mysql01 ~]# mysql -uroot #直接登錄數據庫 mysql> alter user root@localhost identified by 'pwd@111'; mysql> flush privileges; mysql> exit #使用新密碼進(jìn)行登錄測試 [root@mysql01 ~]# mysql -uroot -ppwd@111
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站