【发布时间】:2018-01-04 15:57:57
【问题描述】:
我在本地安装 Wordpress 时遇到此错误:
“建立数据库连接时出错 这意味着您的 wp-config.php 文件中的用户名和密码信息不正确,或者我们无法联系本地主机上的数据库服务器。这可能意味着您主机的数据库服务器已关闭。 "
我在网上搜索了解决方案。大多数人说要检查MySql服务器是否在线(MAMP说是)或更改wp-config-sample.php文件。
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wp_demo');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** 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', '');
我已经做到了,但仍然无济于事。最后一步是将“wp-config-sample.php”文件名更改为“wp-config.php”,这让我遇到了这个错误:
“抱歉,我需要一个 wp-config-sample.php 文件来工作。请从您的 WordPress 安装中重新上传此文件。”
我使用的是 Win 7、MAMP 3.3.1 PHP 7.1.5。 localhost 在 8888 端口。MySql 是 8889 端口
【问题讨论】: