Php 无法安装WordPress错误:";无法连接到数据库";
Ubuntu上的Apache2,没有SELinux 新服务器我正在尝试安装WordPress,但出现错误Php 无法安装WordPress错误:";无法连接到数据库";,php,mysql,wordpress,Php,Mysql,Wordpress,Ubuntu上的Apache2,没有SELinux 新服务器我正在尝试安装WordPress,但出现错误 cannot connect to database 我可以使用命令行登录 mysql -u user -p database 很好,3306端口已通电 root@localhost:/home/www/services.com#netstat-an Active Internet connections (servers and established) Proto Recv-Q Se
cannot connect to database
我可以使用命令行登录
mysql -u user -p database
很好,3306端口已通电
root@localhost:/home/www/services.com#netstat-an
Active 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 :::* LISTEN
root@localhost:/home/www/services.com#cat wp-config.php
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'services.com' );
/** MySQL database username */
define( 'DB_USER', 'services.com' );
/** MySQL database password */
define( 'DB_PASSWORD', '1111' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/** define( 'AUTH_KEY', 'put your unique phrase here' ); */
/** define( 'SECURE_AUTH_KEY', 'put your unique phrase here' ); */
/** define( 'LOGGED_IN_KEY', 'put your unique phrase here' ); */
/** define( 'NONCE_KEY', 'put your unique phrase here' ); */
/** define( 'AUTH_SALT', 'put your unique phrase here' ); */
/** define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); */
/** define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); */
/** define( 'NONCE_SALT', 'put your unique phrase here' ); */
define('AUTH_KEY', 'xxxxx');
define('SECURE_AUTH_KEY', 'xxxxx');
define('LOGGED_IN_KEY', 'xxxxx');
define('NONCE_KEY', 'xxxxx');
define('AUTH_SALT', 'xxxxx');
define('SECURE_AUTH_SALT', 'xxxxx');
define('LOGGED_IN_SALT', 'xxxxx');
define('NONCE_SALT', 'xxxxx');
/**#@-*/
$table_prefix = 'wp_';
define( 'WP_DEBUG', true );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );
完全错误:
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 1633
Warning: 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 1633
The server requested authentication method unknown to the client
Error establishing a database connection
This 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?您正在使用的MySQL 8服务器已将
缓存\u sha2\u密码
插件设置为默认密码插件
(见:和)
7.1.16或7.2.4之前的PHP版本不支持缓存\u sha2\u密码
(见:)
您可以通过直接在mysql控制台中使用查询为当前用户使用mysql\u native\u password
临时修复此问题:
ALTER USER 'services.com'@'localhost' IDENTIFIED WITH mysql_native_password BY '1111';
或者更好的做法是查找并编辑my.cnf(Linux发行版)或my.ini,并将默认\u身份验证\u插件
值更改为:
default_authentication_plugin=mysql_native_password
然后重新启动MySQL服务器 改变用户工作!但是在将条目添加到my.cnf时,我的sql拒绝重新启动。有什么想法吗?你能尝试恢复my.cnf中的更改并重新启动服务器吗?也许您有一个重复的
默认认证插件选项
?MySQL错误日志是怎么说的?
default_authentication_plugin=mysql_native_password