2012-08-08 60 views
1

我是PostgreSQL的新手。創造新角色?

我試圖創建一個名爲pgdba像下面的新角色......

localhost.localdomain:[/home/postgres]createuser -d -i -l -P -r -s pgdba 
new role's password : pgdba 
retype password : pgdba 
password : postgres 

localhost.localdomain:[/home/postgres]psql 
Password: postgres 
psql (9.0.1) 
Type "help" for help. 
postgres=# select * from pg_shadow; 
usename | usesysid | usecreatedb | usesuper | usecatupd |    passwd    | valuntil | useconfig 
----------+----------+-------------+----------+-----------+-------------------------------------+----------+----------- 
postgres |  10 | t   | t  | t   | md53175bce1d3201d16594cebf9d7eb3f9d |   | 
pgdba | 16385 | t   | t  | t   | md53cd688326933adcdedd77097c95d131d |   | 
(2 rows) 

postgres=# \q 

localhost.localdomain:[/home/postgres]psql -U pgdba 
Password for user pgdba: pgdba 
FATAL: database "pgdba" does not exist 

psql: FATAL: database "pgdba" does not exist 

我在做什麼錯?

回答

3

看看這條消息是怎麼回事數據庫 pgdba不存在?

默認情況下,PostgreSQL將連接到以當前用戶命名的數據庫(請參閱the psql docs。由於您未指定要連接的數據庫,因此它試圖連接到名爲pgdba的數據庫 - 該數據庫不存在。

嘗試:

psql -U pgdba postgres 

使用角色pgdba連接到數據庫postgres

您可能還需要檢查pg_hba.conf(見docs如果你想調整認證規則。

順便說一下,你正在運行一個過時的已知錯誤的PostgreSQL版本。請更新至9.0.8系列中的最新補丁版本。你不需要轉儲和重新加載你的數據庫,或者使用pg_upgrade這是一個簡單的替代方案。請參閱release notes瞭解您所缺失的所有修復程序。

而且,而非SELECTpg_shadow荷蘭國際集團,可以考慮使用psql的用戶信息的功能\du\dg,從而產生更好的格式化和綜合信息。