Ubuntu 上的 Apache2,没有 SELinux。我正在尝试安装 WordPress 的新服务器,但出现错误cannot connect to database我可以使用命令行登录mysql -u user -p database很好,端口 3306 是活的。root@localhost:/home/www/services.com# netstat -anActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::80 :::* LISTENroot@localhost:/home/www/services.com# cat wp-config.phproot@localhost:/home/www/services.com# ufw 状态Status: inactive完整错误:Warning: mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /home/www/services.com/wp-includes/wp-db.php on line 1633Warning: mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client in /home/www/services.com/wp-includes/wp-db.php on line 1633The server requested authentication method unknown to the clientError establishing a database connectionThis either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down. Are you sure you have the correct username and password? Are you sure you have typed the correct hostname? Are you sure the database server is running?If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.我还检查了用户名中的空格或错误,并阅读了许多其他类似的帖子。如何让 WordPress 连接到 MySQL?
1 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
您使用的 MySQL 8 服务器已将caching_sha2_password
插件设置为默认密码插件。
(参见:https ://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html和https://dev.mysql.com/doc/refman/8.0/en/upgrading -from-previous-series.html#upgrade-caching-sha2-password)
7.1.16 或 7.2.4 之前的 PHP 版本不支持caching_sha2_password
.
(见:https ://www.php.net/manual/en/mysqli.requirements.php )
mysql_native_password
您可以通过直接在 mysql 控制台中使用查询来临时解决此问题:
ALTER USER 'services.com'@'localhost' IDENTIFIED WITH mysql_native_password BY '1111';
或者更好的是找到并编辑 my.cnf (Linux Distros) 或 my.ini 并将default_authentication_plugin
值更改为:
default_authentication_plugin=mysql_native_password
并重新启动 MySQL 服务器。
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报
0/150
提交
取消