feat: doc/postgres-create-user.md

This commit is contained in:
dancingCycle 2023-11-16 10:27:45 +01:00
parent 3ab07df114
commit cabf42079a
1 changed files with 8 additions and 8 deletions

View File

@ -1,35 +1,35 @@
# Create User with Postgres # Create User with Postgres
* create a database user called <user name> with password <key> * create a database user called `user name` with password `key`
``` ```
CREATE USER <user name> with encrypted password '<key>'; CREATE USER `user name` with encrypted password 'key';
``` ```
* OPTION: gant user <user_name> access to database <database name> * OPTION: gant user `user name` access to database `database name`
``` ```
GRANT ALL PRIVILEGES ON DATABASE <database name> TO <user name>; GRANT ALL PRIVILEGES ON DATABASE <database name> TO <user name>;
``` ```
* OPTION: add all privileges for a <schema name> to a <user> * OPTION: add all privileges for a `schema name` to a `user`
``` ```
GRANT ALL PRIVILEGES ON ALL TABALES ON SCHEMA <schema name> TO <user name>; GRANT ALL PRIVILEGES ON ALL TABALES ON SCHEMA <schema name> TO <user name>;
``` ```
* OPTION: if <user name> already exist, pw can be changed this way * OPTION: if `user name` already exist, pw can be changed this way
``` ```
ALTER USER <user name> WITH ENCRYPTED PASSWORD '<key>'; ALTER USER <user name> WITH ENCRYPTED PASSWORD '<key>';
``` ```
* OPTION: gant user <user_name> access to database ```postgres``` so that this user is able to login without providing a database * OPTION: gant user `user name` access to database `postgres` so that this user is able to login without providing a database
``` ```
sudo -u postgres psql -W sudo -u postgres psql -W
GRANT ALL PRIVILEGES ON DATABASE postgres to <user name>; GRANT ALL PRIVILEGES ON DATABASE postgres to <user name>;
``` ```
* OPTION: gant user <user_name> permission to create databases * OPTION: gant user `user name` permission to create databases
``` ```
sudo -u postgres psql -W sudo -u postgres psql -W
ALTER USER <user_name> CREATEDB; ALTER USER <user name> CREATEDB;
``` ```
* edit the pg_hba.conf file\ * edit the pg_hba.conf file\