【问题标题】:User can always connect to the database [POSTGRES]用户始终可以连接到数据库 [POSTGRES]
【发布时间】:2017-04-06 08:19:19
【问题描述】:

我与用户“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

稍后,我尝试将用户“user”连接到“db_example”:

root@debian:/home/debian# psql -d db_example -U user -h localhost

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=>

为什么我可以将用户“user”连接到“db_example”?

感谢您的帮助和美好的一天。

【问题讨论】:

标签: postgresql login psql grant


【解决方案1】:

这是因为PUBLIC(即所有人)默认拥有该权限。

要删除它,请运行

REVOKE CONNECT ON DATABASE db_example FROM PUBLIC;

运行\l+ 以查看当前在数据库上设置的权限。 空设置表示默认值:所有者可以做任何事情,PUBLIC 可以连接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 2016-08-21
    • 2021-07-14
    • 2017-11-12
    相关资源
    最近更新 更多