WordPress 'Error establishing a database connection'

WordPress 'Error establishing a database connection'

我正在尝试在 WordPress 中开始我的第一个项目,并将这些数据放入

  1. Database Name : wp-project-1
  2. DB_USER : root
  3. DB_PASSWORD:``
  4. DB_HOST : localhost
  5. Table Prefix : wp_

在我的 wp-config-sample.php:

define( 'DB_NAME', 'wp-project-1' );

/** MySQL database username */
define( 'DB_USER', 'root' );

/** MySQL database password */
define( 'DB_PASSWORD', '' );

/** 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', '' );

但是提交的时候提示这样的错误:

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.

这里我用的是xampp服务器,我的xampp端口号是3307(我改了,因为3306每次都忙。)

我该如何解决?

在 xampp 上,您可以打开控制面板,其中显示 apache 命中配置 select php ini 并找到以下内容

mysqli.default_port=

请将您的 wp-config-sample.php 文件更改为 wp-config.php