8.0.34-0 ubuntu 安裝Mysql 后無法鏈接是什么情況
- 檢查日志
- 解決辦法
檢查日志
如果檢查一下帳號密碼沒問題看一下日志:
Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
很顯然是mysql 采用的密碼插件出了問題:你采用了mysql廢棄的密碼驗證方式:
Plugin mysql_native_password reported: ‘mysql_native_password’ is deprecated and will be removed in a future release. Please use caching_sha2_password instead
解決辦法
這時候你可以通過SQL來更新認證模式和密碼:
update user set plugin = 'caching_sha2_password' where user = '用戶名';
操作之前先選擇mysql庫
對于PHP來說,使用7.1(7.1.16之前的版本)或者7.2(7.2.4之前的版本),仍需要將MySQL服務器的默認密碼插件設置為mysql_native_password,不然無法正常連接到MySQL。