「CentOS8.3」PostgreSQL12のロール、データベースを作成する方法

1.データベースへ接続
# su –c 'psql’ postgres
psql: /lib64/libpq.so.5: no version information available (required by psql)
psql: /lib64/libpq.so.5: no version information available (required by psql)
psql: /lib64/libpq.so.5: no version information available (required by psql)
could not change directory to “/root": 許可がありません
psql (12.5)
Type “help" for help.

postgres=#

2.データベースの切断
# \q

3.ロール作成
# create role arkuser createdb login password 'arkpwd’;
CREATE ROLE

ロールの一覧を表示
# \du
List of roles
Role name | Attributes | Member of
————-+————————————————————+———–
arkuser | Create DB | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

4.「create database」でデータベースの作成
# create database arkdb owner arkuser;
CREATE DATABASE
データベースの一覧を表示
# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
———–+———-+———-+———+——-+———————–
arkdb | arkuser | UTF8 | C | C |
postgres | postgres | UTF8 | C | C |

CentOS

Posted by arkgame