Fedora37 PostgreSQL ユーザーを追加する方法

環境
OSバージョンを確認します
# cat /etc/redhat-release
Fedora release 37 (Thirty Seven)
PostgreSQL 14.3

操作方法
1.OSユーザーを追加します
# useradd arte01

2.PostgreSQL 管理ユーザーで PostgreSQL ユーザーとデータベースを追加します
[root@localhost ~]# su – postgres
[postgres@localhost ~]$ createuser arte01
[postgres@localhost ~]$ createdb testdb -O arte01

ユーザー名を確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[postgres@localhost ~]$ psql -c "select usename from pg_user;"
usename
----------
postgres
arte01
(2)
[postgres@localhost ~]$ psql -c "select usename from pg_user;" usename ---------- postgres arte01 (2 行)
[postgres@localhost ~]$ psql -c "select usename from pg_user;"
usename
----------
postgres
arte01
(2 行)

3.データベースを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[postgres@localhost ~]$ psql -l
データベース一覧
名前 | 所有者 | エンコーディング | 照合順序 | Ctype(変換演算子) | アクセス権限
-----------+----------+------------------+-------------+-------------------+-----------------------
postgres | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 |
template0 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | arte01 | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 |
(4)
[postgres@localhost ~]$ psql -l データベース一覧 名前 | 所有者 | エンコーディング | 照合順序 | Ctype(変換演算子) | アクセス権限 -----------+----------+------------------+-------------+-------------------+----------------------- postgres | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | template0 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres testdb | arte01 | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | (4 行)
[postgres@localhost ~]$ psql -l
                                         データベース一覧
   名前    |  所有者  | エンコーディング |  照合順序   | Ctype(変換演算子) |     アクセス権限
-----------+----------+------------------+-------------+-------------------+-----------------------
 postgres  | postgres | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       |
 template0 | postgres | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       | =c/postgres          +
           |          |                  |             |                   | postgres=CTc/postgres
 template1 | postgres | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       | =c/postgres          +
           |          |                  |             |                   | postgres=CTc/postgres
 testdb    | arte01   | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       |
(4 行)

 

Fedora 37

Posted by arkgame