Ubuntu 16.04下忘記MySQL密碼解決方法
阿新 • • 發佈:2018-12-03
I. 在終端輸入sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
II. 在[mysqld]
下方的skip-external-locking
下面新增一行:
skip-grant-tables
III. 重啟MySQL服務:
sudo service mysql restart
IV. 在終端輸入命令:mysql
進入mysql
V. 輸入USE mysql
(切換至mysql
資料庫)
VI. 將root
使用者的密碼修改為0000
:
UPDATE mysql.user SET authentication_string=password('0000') WHERE User='root' AND Host ='localhost';
VII. 修改欄位plugin:
UPDATE user SET plugin="mysql_native_password";
(Plugin欄位標識可以用於驗證使用者身份的外掛,如果欄位為空,伺服器使用內建授權驗證機制驗證使用者身份。 )
VIII. 輸入flush privileges;
IX. 輸入quit;
X. 把/etc/mysql/mysql.conf.d/mysqld.cnf
檔案中新增的一行註釋掉
--------------------- 作者:rhanqtlnuse 來源:CSDN 原文:https://blog.csdn.net/hq815601489/article/details/78608644?utm_source=copy 版權宣告:本文為博主原創文章,轉載請附上博文連結!