「PostgreSQL 13.2」create userコマンドでユーザーを作成する方法

環境
Windows 10 64bit
PostgreSQL 13.2

使用例1
ユーザー名「ark」を作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# create user ark;
create role
postgres=# create user ark; create role
postgres=# create user ark;
create role

使用例2
ユーザー名「ark」をパスワード「ark」で作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# create user ark with password 'ark';
create role
postgres=# create user ark with password 'ark'; create role
postgres=# create user ark with password 'ark';
create role

使用例3
パスワードの期限を2023年1月23日の終わりまで有効とする

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# create user ark with password 'ark' valid until 'jan 23 2023';
create role
postgres=# create user ark with password 'ark' valid until 'jan 23 2023'; create role
postgres=# create user ark with password 'ark' valid until 'jan 23 2023';
create role

使用例4
権限にデータベース作成権限、ユーザー作成権限を設定します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# create user ark with password 'ark' createdb createrole;
create role
postgres=# create user ark with password 'ark' createdb createrole; create role
postgres=# create user ark with password 'ark' createdb createrole;
create role

使用例5
ユーザー名「ark」をパスワード「ark」で作成し、スーパーユーザー権限とします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# create user ark with password 'ark' superuser;
create role
postgres=# create user ark with password 'ark' superuser; create role
postgres=# create user ark with password 'ark' superuser;
create role

 

PostgreSQL

Posted by arkgame