共計(jì) 707 個(gè)字符,預(yù)計(jì)需要花費(fèi) 2 分鐘才能閱讀完成。
自動(dòng)寫代碼機(jī)器人,免費(fèi)開通
這篇文章給大家分享的是有關(guān) mysql5.7 重置 root 密碼的方法的內(nèi)容。丸趣 TV 小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考。一起跟隨丸趣 TV 小編過來看看吧。
安裝完 mysql5.7 后忘記了密碼,需要重置 root 密碼;
第一步:修改配置文件免密碼登錄 mysql
vim /etc/my.cnf
## 在 my.cnf 的 [mysqld] 字段加入
skip-grant-tables
## 重啟 mysql 服務(wù)
service mysqld restart
第二步:免密碼登錄 mysql
mysql -u root
##password 直接回車
第三步:給 root 重置密碼為空
mysql use mysql;
## mysql 5.7.9 以后廢棄了 password 字段, 字段名修改為 authentication_string
mysql update user set authentication_string= where user= root
## 刷新數(shù)據(jù)庫
mysql flush privileges;
第四步:root 重置密碼
??退出 mysql,刪除 /etc/my.cnf 文件最后的 skip-grant-tables 重啟 mysql 服務(wù),使用 root 用戶進(jìn)行登錄,因?yàn)樯厦嬖O(shè)置了 authentication_string 為空,所以可以免密碼登錄。
alter user root @ localhost identified by #新密碼 #
感謝各位的閱讀!關(guān)于 mysql5.7 重置 root 密碼的方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
向 AI 問一下細(xì)節(jié)
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!
正文完
發(fā)表至: 數(shù)據(jù)庫
2023-12-18