deepin和ubuntu中mysql8.0.16修改密碼蜜汁問題

下面只是修改密碼的記錄

# # # # # # # # # # # # # # # # 首次修改密碼# # # # # # # # # # # # # # # # 
關閉正在運行的 MySQL :
# service mysqld stop
運行
# mysqld_safe --skip-grant-tables &
爲了安全可以這樣禁止遠程連接:
# mysqld_safe --skip-grant-tables --skip-networking &
使用mysql連接server:
# mysql -p

update mysql.user set authentication_string=password('%1q2w3e4r%') where user='root' and Host = 'localhost';
flush privileges;
quit;

# # # # # # # # # # # # # # # # 忘記修改密碼 1# # # # # # # # # # # # # # # # 
方法1:
1:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

2:[mysqld]這一塊中加入skip-grant-tables這句話。


3:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1q2w3e4r';
會報錯:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement


4: flush privileges;
Query OK, 0 rows affected (0.05 sec)

5: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1q2w3e4r';
Query OK, 0 rows affected (0.08 sec)

6: flush privileges;
Query OK, 0 rows affected (0.03 sec)

7: quit

8:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

9:[mysqld]這一塊中刪除skip-grant-tables這句話。

10:/etc/init.d/mysql restart

這種方法,我剛安裝好的時候嘗試我也是失敗不懂爲什麼,下面提示的語法錯誤,仔細自己看了一篇沒有錯誤。可能哪裏錯誤沒發現吧!最後把下面也都嘗試過,最後還是這個解決了。簡直感覺太神奇了存在了

# # # # # # # # # # # # # # # # 忘記修改密碼 2# # # # # # # # # # # # # # # # 

查看mysql版本:SELECT @@VERSION


在ubuntu的terminal(也即終端)上輸入sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf,進入到這個配置文件,然後在這個配置文件中的[mysqld]這一塊中加入skip-grant-tables這句話。
esc鍵輸入:wq(保存退出。並退出)輸入:service mysql restart(重新啓動mysql。)或者 /etc/init.d/mysql restart
mysql -u root -p
1 use mysql;   然後敲回車
2 update user set authentication_string=password("你的密碼") where user="root";  然後敲回車反正我的不行換成下面一句執行的執行成功了執行錢flush privileges;
 update user set authentication_string=password("ln122920"),plugin='mysql_native_password' where user='root';
這句就是root的plugin爲auth_socke,其他的爲"mysql_native_password" 這個執行玩flush privileges;提交退出在重新進,在按上面的2修改密碼執行應該可以成功
3 flush privileges;  然後敲回車

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章