Create a new login role postgres
To create a new login role in PostgreSQL, you can use the following command:
CREATE ROLE new_role_name WITH PASSWORD 'password';
Replace new_role_name
with the name you want to give to the new role, and password
with the password you want to set for the role.
For example:
CREATE ROLE my_new_role WITH PASSWORD 'my_secret_password';
This will create a new role named my_new_role
with the password my_secret_password
.
You can also add additional options to the CREATE ROLE
command to customize the role's behavior. For example:
SUPERUSER
: grants the role superuser privileges, allowing it to perform any operation in the database.CREATEROLE
: grants the role the ability to create new roles.CREATEDB
: grants the role the ability to create new databases.REPLICATION
: grants the role the ability to replicate the database.INHERIT
: allows the role to inherit privileges from its parent roles.
Here is an example of creating a new role with some additional options:
CREATE ROLE my_new_role WITH PASSWORD 'my_secret_password' SUPERUSER CREATEROLE CREATEDB;
This will create a new role named my_new_role
with the password my_secret_password
, and grant it superuser privileges, the ability to create new roles, and the ability to create new databases.
You can also use the ALTER ROLE
command to modify an existing role. For example:
ALTER ROLE my_new_role WITH PASSWORD 'new_password';
This will change the password for the my_new_role
role to new_password
.
Note: You need to be a superuser (such as the postgres
user) to create a new role in PostgreSQL.