[PostgreSQL]データベースに接続するロールのパスワードを変更

1.データベースに接続

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
>psql -U cft055 -d postgres
ユーザ cft055 のパスワード:test123
psql (9.6.5)
"help" でヘルプを表示します.
>psql -U cft055 -d postgres ユーザ cft055 のパスワード:test123 psql (9.6.5) "help" でヘルプを表示します.
>psql -U cft055 -d postgres
ユーザ cft055 のパスワード:test123
psql (9.6.5)
"help" でヘルプを表示します.

2.接続用パスワードを変更

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=> alter role session_user with password 'test456';
ALTER ROLE
postgres=> alter role session_user with password 'test456'; ALTER ROLE
postgres=> alter role session_user with password 'test456';
ALTER ROLE

3.権限を変更

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=> alter role cft055 with createrole;
ALTER ROLE
postgres=> \q
postgres=> alter role cft055 with createrole; ALTER ROLE postgres=> \q
postgres=> alter role cft055 with createrole;
ALTER ROLE
postgres=> \q

4.再度データベースに接続

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
>psql -U cft055 -d postgres
ユーザ cft055 のパスワード:test456
psql (9.6.5)
"help" でヘルプを表示します.
postgres=>
>psql -U cft055 -d postgres ユーザ cft055 のパスワード:test456 psql (9.6.5) "help" でヘルプを表示します. postgres=>
>psql -U cft055 -d postgres
ユーザ cft055 のパスワード:test456
psql (9.6.5)
"help" でヘルプを表示します.

postgres=>

 

PostgreSQL

Posted by arkgame