mysql密碼的坑

  一段時間沒用本機的mysql,忘了root密碼,從網上找的修改方法用起來大多都有問題。mysql版本8.0.12。mysql

  網上大多數思路:修改msql啓動方式爲帶--skip-grant-tables參數;而後免密進入客戶端修改密碼。但在skip-grant-tables模式下只能用update方法,但使用password函數的時候總報錯。
sql

  後來找的方式:函數

  一、以skip-grant-tables參數啓動mysql --skip-grant-tables。或者修改啓動ini文件。
加密

  二、免密進入客戶端:mysql -uroot
spa

  三、清空root密碼:update user set authentication_string='' where user='root';.net

  四、正常啓動mysql插件

  五、使用alter user命令修改root密碼:ALTER user 'root'@'localhost' IDENTIFIED BY 'urpass';
code

  六、更換密碼加密方式(可選):ALTER user 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'urpass';blog

 

  七、查看相關信息:select host, user, authentication_string, plugin from user;ip

  核心緣由就是密碼加密插件問題。連接在此

相關文章
相關標籤/搜索