忘記Mysql密碼的解決辦法小結
更新時間:2014年07月02日 17:06:22 投稿:hebedich
最近老是忘記mysql密碼。網上學習了四種解決辦法,記錄下來。分享給大家
方法1: 用SET PASSWORD命令
mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
方法2:用mysqladmin
mysqladmin -u root password "newpass"
如果root已經設置過密碼,采用如下方法
mysqladmin -u root password oldpass "newpass"
方法3: 用UPDATE直接編輯user表
mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;
在丟失root密碼的時候,可以這樣
mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root'; mysql> FLUSH PRIVILEGES;
希望對大家有所幫助。
相關文章
phpstudy中mysql無法啟動(與本地安裝的mysql沖突)的解決方式
這篇文章主要給大家介紹了關于phpstudy中mysql無法啟動(與本地安裝的mysql沖突)的解決方式,文中通過圖文將解決的方法介紹的非常詳細,需要的朋友可以參考下2022-09-09Mysql錯誤Every derived table must have its own alias解決方法
這篇文章主要介紹了Mysql錯誤Every derived table must have its own alias解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2019-08-08解決MySQL報錯1267 - Illegal mix of coll
這篇文章主要給大家介紹了解決MySQL報錯1267 - Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPL的問題,文中有詳細的解決方案,需要的朋友可以參考下2023-09-09