wordpress 安装提示 Error Establishing a Database Connection

出现这个提示 Error Establishing a Database Connection,表示 wordpress 在连接数据库的时候没有成功。最基本的是检查连接 mysql 的用户名和密码,以及 mysql 服务是否正常运行。

我用的是 mysql8.0,因此导致这个提示错误的原因既不是密码不正确,也不是 mysql 服务未启动。而是 mysql 账号密码的加密算法是 wordpress 所不支持的。

mysql8 支持的验证方法:

加密方法 实现
mysql_native_password implements native authentication
sha256_password Implements basic SHA-256 authentication
caching_sha2_password Implements SHA-256 authentication (like sha256_password), but uses caching on the server side for better performance and has additional features for wider applicability

将 root 账号的密码的加密方法改为传统 mysql 加密方法

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpasswd';

然后点击重试,重新安装 wordpress。

参考链接:

原文地址:https://www.cnblogs.com/imzhi/p/wordpress-mysql8-error-connection.html