创建数据库bbb且owner为用户b:
postgres9.6@[local]:5432 postgres# create database bbb owner b;
CREATE DATABASE
Time: 259.099 ms
默认情况下使用用户c也可以连接数据库bbb:
postgres9.6@[local]:5432 postgres# \c bbb c
You are now connected to database "bbb" as user "c".
回收public的connect on database bbb权限:
c@[local]:5432 bbb# \c postgres postgres9.6
You are now connected to database "postgres" as user "postgres9.6".
postgres9.6@[local]:5432 postgres# revoke connect on database bbb from public;
REVOKE
Time: 2.088 ms
此时用户c没有了连接数据库bbb的权限:
postgres9.6@[local]:5432 postgres# \c bbb c
FATAL: permission denied for database "bbb"
DETAIL: User does not have CONNECT privilege.
Previous connection kept
但bbb数据库的owner用户b可以连接数据库:
p