2016-11-22 29 views
0

我對用戶「Postgres的」連接並創建一個用戶:用戶可以隨時連接到數據庫[POSTGRES]

postgres=# CREATE DATABASE db_example ; 
postgres=# CREATE USER user WITH PASSWORD 'user123'; 
postgres=# REVOKE CONNECT ON DATABASE db_example FROM user; 
REVOKE 
postgres=# \q 

後來,我嘗試對用戶「用戶」到「db_example」連接:

根@ debian的:/家庭/ Debian的#PSQL -d db_example -U用戶-h本地主機

psql (9.4.9) 
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) 
Type "help" for help. 

db_example=> 

瓦我可以連接到用戶「用戶」到「db_example」嗎?

感謝您的幫助和美好的一天。

+0

可能的重複[爲什麼PostgreSQL中的新用戶可以連接到所有數據庫](http://stackoverflow.com/questions/6884020/why-new-user-in-postgresql-can-connect-to-all-databases ) – cske

回答

1

那是因爲PUBLIC(即每個人)默認具有該特權。

要刪除,運行

REVOKE CONNECT ON DATABASE db_example FROM PUBLIC; 

運行\l+看到當前的數據庫設置權限。 空白設置表示默認值:所有者可以做所有事情,並且PUBLIC可以連接。

+0

非常感謝,你解決了我的問題:) – Python241820

相關問題