PostgreSQL User Security Configuration

Source: Internet
Author: User
Tags postgresql psql

First, configuration instructions:

Role Name: User01

1.user01 Permission Description:

Connect to test database, cannot connect to other database when unauthorized;

In the specified schema, create \ View \ Delete The table to view the object in the schema;

2. Other Ordinary users:

Cannot connect object in test database and schema (sales), need authorization;


Second, the operation steps:

    1. Instance (instance level): Role (roles)

$ psql Postgres

postgres=# CREATE ROLE User01 LOGIN nosuperuser nocreatedb;


2.database (db level): CREATE (schemas) and CONNECT (database)

$ psql Postgres

postgres=# CREATE DATABASE test;

postgres=# REVOKE all on the DATABASE test from public; --Prohibit other common role connection test

postgres=# GRANT CONNECT on the DATABASE test to User01;


3.schema (Schema level):

CREATE (Put object into schema)

USAGE (allow us to actually look into a schema and see which objects is present).

$psql Test

test=# REVOKE All on the SCHEMA public from public;--Other common role cannot connect test

test=# CREATE SCHEMA Sales;

CREATE SCHEMA

test=# GRANT create,usage on the SCHEMA sales to User01; --User01 can create and view objects in sales

GRANT

test=# \q


$ psql test-u User01

Test=> CREATE TABLE sales.t_sales (id int4);

CREATE TABLE


4.table (Table level): Grant

Default User01 creation, drop table, and DML table content

5.column (Column level): Grant

Default User01 creation, drop table, and DML column contents


This article is from the "Yiyi" blog, make sure to keep this source http://heyiyi.blog.51cto.com/205455/1871200

PostgreSQL User Security Configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.