2015-01-12 81 views
0

我已經在面對MySQL設置時解決了這個問題,但是當我們使用PG的時候,我似乎沒有辦法解決這個問題。建立數據庫連接時出錯 - 使用Postgres/pg4wp

問題:錯誤建立一個數據庫連接

這裏是我的wp-config.php文件:

// ** Heroku Postgres settings - from Heroku Environment ** // 
$db = parse_url($_ENV["DATABASE_URL"]); 
if($_SERVER["SERVER_NAME"]==="localhost") { 
define('DB_NAME','finpipe_dev_db'); 
/** MySQL database username */ 
define('DB_USER','ilia'); 
/** MySQL database password */ 
define('DB_PASSWORD','ilia'); 
/** MySQL hostname */ 
define('DB_HOST','localhost'); 
} else { 
// ** Heroku Postgres settings - from Heroku Environment ** // 
// ** MySQL settings - You can get this info from your web host ** // 
/** The name of the database for WordPress */ 
define('DB_NAME',trim($db["path"],"/")); 
/** MySQL database username */ 
define('DB_USER',$db["user"]); 
/** MySQL database password */ 
define('DB_PASSWORD',$db["pass"]); 
/** MySQL hostname */ 
define('DB_HOST',$db["host"]); 
} 
/** 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',''); 

這裏是被Postgres的控制檯中我的輸出:

List of databases 
     Name  | Owner | Encoding | Collate | Ctype | Access privileges 
--------------------+----------+----------+-------------+-------------+----------------------- 
finpipe_dev_db  | ilia  | UTF8  | en_CA.UTF-8 | en_CA.UTF-8 | 

我已經完成ALTER USER ilia WITH PASSWORD 'ilia';

然而,仍然受到打擊錯誤建立 ...

這是怎麼回事?

回答

0

你得到的這個錯誤可能是因爲PostgreSQL不接受連接。請檢查PostgreSQL實例目錄中的pg_hba.conf和postgresql.conf文件,您可能必須配置它們以便能夠訪問您的數據庫。

嘗試配置以下和測試,如果一切正常,你需要找到正確的配置(這一個允許所有)

的pg_hba.conf

# IPv4 local connections: 
host all    all    0.0.0.0/0    md5 

postgresql.conf中

listen_addresses = '*' 
相關問題