2016-02-26 16 views

回答

1

默認情況下,連接到數據庫的權限授予public角色。

因此,您需要做的第一件事就是撤消這個。爲此,請以超級用戶身份登錄到該數據庫(通常爲postgres),例如

psql -U postgres new_database 

然後在SQL提示符下運行:

revoke connect on database new_database from public; 

然後,你需要的權限授予每個用戶:

grant connect on database new_database to user_1; 
grant connect on database new_database to user_2; 

替換new_database與您創建的數據庫的名稱。

您還可以通過pg_hba.conf來控制對服務器的訪問,但這有點複雜。詳情請參閱手冊:http://www.postgresql.org/docs/current/static/client-authentication.html

相關問題