創新互聯www.cdcxhl.cn八線動態BGP香港云服務器提供商,新人活動買多久送多久,劃算不套路!

小編給大家分享一下解決mysql忘了root密碼的方法,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
mysql忘了root密碼解決方法:
1、修改配置文件my.cnf,在配置文件[mysqld]下添加skip-grant-tables,重啟MySQL服務即可免密碼登錄
# SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # [mysqld] skip-grant-tables
2、用空密碼的 root 用戶連接到 MySQL,并且更改 root 口令:
[root@localhost mysql]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 53 Server version: 5.0.41-community-log MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123'; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> update user set authentication_string = NULL where user = 'root'; Query OK, 1 row affected (0.00 sec)
上面是先用grant的方式修改root密碼,但是由于使用了配置了skip-grant-tables 選項,使用“alter user”命令更改密碼失敗,直
接更新 user 表的 authentication_string字段后更改密碼成功。
3、到my.cnf 中刪除skip-grant-tables選項,然后直接用mysql -uroot免密碼登錄后,在執行如下語句重設密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
看完了這篇文章,相信你對解決mysql忘了root密碼的方法有了一定的了解,想了解更多相關知識,歡迎關注創新互聯-成都網站建設公司行業資訊頻道,感謝各位的閱讀!
當前題目:解決mysql忘了root密碼的方法-創新互聯
網頁地址:http://www.yijiale78.com/article34/pipse.html
成都網站建設公司_創新互聯,為您提供搜索引擎優化、App設計、網站設計、品牌網站制作、網站排名、做網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯