Why new user in PostgreSQL can connect to all databases?

孤街醉人 提交于 2019-11-30 04:03:26
Lekensteyn

From http://www.postgresql.org/docs/9.2/static/sql-grant.html#SQL-GRANT-DESCRIPTION-OBJECTS (emphasis mine):

PostgreSQL grants default privileges on some types of objects to PUBLIC. No privileges are granted to PUBLIC by default on tables, columns, schemas or tablespaces. For other types, the default privileges granted to PUBLIC are as follows: CONNECT and CREATE TEMP TABLE for databases; EXECUTE privilege for functions; and USAGE privilege for languages. The object owner can, of course, REVOKE both default and expressly granted privileges. (For maximum security, issue the REVOKE in the same transaction that creates the object; then there is no window in which another user can use the object.) Also, these initial default privilege settings can be changed using the ALTER DEFAULT PRIVILEGES command.

In order to remove all privileges (including CONNECT) for all unspecified users on a database, use:

REVOKE ALL PRIVILEGES ON DATABASE <database> FROM public;

See also:

You probably also need to modify the pg_hba.conf file. By default, a local installation doesn't do authorization checks.

You must use GRANT and/or REVOKE to define the privileges for the user or role. You can also use the following link functions to see if a user has a specific privilege on a table, database, etc...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!