在OS X上安装wordpress错误建立连接

问题描述:

我真的很困惑wordpress安装。 wp_config文件具有我的mysql(localhost)实例的根用户名和密码,并且我创建了一个名为'wordpress'的空白数据库(我不确定我是否应该创建一个数据库)。在OS X上安装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'); 
+1

试过这个。不为我工作:/ – user3789629 2016-01-07 16:03:39

与WordPress,你应该有一个数据库已经建立(无表,只是数据库)。

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

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

然后是该用户的密码。

然后,最后,主机通常是localhost,但如果你在共享主机上,它可能会有所不同。您必须检查您的托管服务提供商文档以确保。

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