WordPress 建立資料庫連線失敗之 ER_NOT_SUPPORTED_AUTH_MODE
阿新 • • 發佈:2020-08-17
目錄
報錯場景
WordPress 提示 "建立資料庫連線失敗"。開啟 WordPress 的除錯模式,檢視詳情報錯原因。
wp-config.php
裡的程式碼修改為:
define('WP_DEBUG', true);
如果具體的報錯原因是:
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
說明 MySQL 客戶端不支援 MySQL8 的新的加密驗證方式 caching_sha2_password
解決方法
A)臨時解決,修改使用者的密碼為老的加密方式:
ALTER USER myuser IDENTIFIED WITH mysql_native_password BY 'mypassword';
B)修改 MySQL 預設的加密方式:
$ sudo cp /etc/my.cnf /etc/my.cnf.backup.20181027.001
$ sudo nano /etc/my.cnf
在 [mysqld] 區塊加入以下內容:
[mysqld]
default_authentication_plugin=mysql_native_password
重啟 MySQL:
$ sudo systemctl restart mysqld
參考文章:
How to fix Wordpress database connection for MySQL 8
How to change caching_sha2_password to mysql_native_password on a DigitalOcean's Managed MySQL Database? | DigitalOcean