欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL 5.7及8.0版本數(shù)據(jù)庫(kù)的root密碼遺忘的解決方法

 更新時(shí)間:2019年12月11日 09:02:26   作者:warrent  
這篇文章主要介紹了MySQL 5.7及8.0版本數(shù)據(jù)庫(kù)的root密碼遺忘的解決辦法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧

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

1、遺忘MySQL 5.7數(shù)據(jù)庫(kù)的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這行下寫入下面內(nèi)容
skip-grant-tables
      .................#省略部分內(nèi)容
[root@mysql01 ~]# systemctl restart mysqld   #重啟MySQL服務(wù),使配置文件生效
[root@mysql01 ~]# mysql -uroot      #跳過(guò)密碼驗(yàn)證,直接登錄數(shù)據(jù)庫(kù)
#修改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
#配置密碼驗(yàn)證,使用新密碼登錄
[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ù)庫(kù)的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      #跳過(guò)密碼驗(yàn)證,直接登錄數(shù)據(jù)庫(kù)
#將root密碼設(shè)置為空
mysql> use mysql
mysql> update user set authentication_string='' where user = 'root';
mysql> flush privileges;
mysql> exit
#開啟密碼驗(yàn)證并重新登錄數(shù)據(jù)庫(kù)
[root@mysql01 ~]# vim /etc/my.cnf     #編輯主配置文件
[mysqld] 
skip-grant-tables      #刪除此行
[root@mysql01 ~]# systemctl restart mysqld     #重啟使更改生效
[root@mysql01 ~]# mysql -uroot      #直接登錄數(shù)據(jù)庫(kù)
mysql> alter user root@localhost identified by 'pwd@111';
mysql> flush privileges;
mysql> exit
#使用新密碼進(jìn)行登錄測(cè)試
[root@mysql01 ~]# mysql -uroot -ppwd@111

總結(jié)

以上所述是小編給大家介紹的MySQL 5.7及8.0版本數(shù)據(jù)庫(kù)的root密碼遺忘的解決辦法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!

相關(guān)文章

最新評(píng)論