1. During the data initialization phase during PostgreSQL installation, a role named Postgres is created by default (and a database named Postgres is created).
2. The ident authentication mechanism can be used to map the root user of the operating system to the PostgreSQL role of the data, so that the root user can log in without a password directly
3. Create a role with login privileges
postgres=# Create role Leo login password ' king ' createdb valid until ' infinity ';
The valid line is optional, and its function is to set the validity period for this role, all permissions expire after expiration, and the default time limit is infinity, which never expires.
The Createdb modifier indicates that permissions to create a database are given to this role
4. Create a role with superuser privileges
postgres=# Create role Regina login password ' Queen ' superuser valid until ' 2019-1-1 00:00 ';
5. Create a group role
postgres=# Create role Royalty INHERIT;
Inherit indicates that any of the member roles of group role royalty will automatically inherit all of its permissions except Superuser rights.
To grant the permissions of a group role to its member role
postgres=# Grant royalty to leo;postgres=# Grant royalty to Regina;
This article is from the "Corasql" blog, make sure to keep this source http://corasql.blog.51cto.com/5908329/1914386
PostgreSQL Learning Notes (iv) roles