First, use superuser to connect to the database
By default, the Super User is set to ipvs.
The connection script command is Psql. This is in the bin directory of the installation directory.
/Bin $ Psql
Postgres -#
Create a user. Create a database under user management
Postgres-# create role John login createrole createdb password 'john'; // grant permissions to John: logon permission, create user permission, and create database permission. And grant the user the permission to use the password to log on.
Create USER commands
The create USER command is equivalent to the create role command,
Note that the login attribute is already set by default when you use create user. However, role is not the default one.
Create a user. Yes, this user has the right to create a database.
UseCreate roleNameCreatedb
Generally, other permissions are assigned to role. For example, one role can be used to create another role.
UseCreate role
NameCreaterole
Query USER commands
Check if the created user is successfully created. Run the S-# \ du command.
After creating a user, create a database managed by the user
Postgres-# create database mss owner John;
Show all databases
Postgres-# \ L
To log out of the current user, run the \ q command.
How can I create and use a user and log on to a database under the user management.