在OS X上安装wordpress时,连接失败


Installing wordpress on OS X error establishing connection

我真的被wordpress的安装弄糊涂了。wp_config文件有root用户名和密码为我的mysql (localhost)的实例,我已经创建了一个名为"wordpress"的空白数据库(我不确定我是否应该有一个数据库创建开始)。

当我访问http://localhost/wordpress/时,我得到一条'Error establishing a database connection'消息。我应该有一个数据库称为"wordpress"开始吗?

这些是我在配置文件中的凭据:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'friday');
/** 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', '');

参见http://techtrouts.com/mac-mysql-does-not-connect-on-localhost-but-connects-on-127001/关于这个的一些信息。

基本上,在Mac的默认安装中,您必须连接到127.0.0.1而不是localhost。因此,如果您更改以下内容,它应该可以工作。

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

使用Wordpress,你应该已经有了一个数据库设置(没有表,只有数据库)。

所以第一个选项应该是数据库名称。如果您使用的是共享主机,那么在数据库名称之前可能会有一个前缀。

然后是数据库的用户(在设置数据库时应该设置)。

然后是该用户的密码。

最后,主机通常是localhost,但是如果您使用的是共享主机,情况可能会有所不同。你必须检查你的托管服务提供商的文档来确定。

同样,你应该去的第一个地方是:http://localhost/wordpress/wp-admin/install.php