日本PostgreSQLユーザ会 | 日本PostgreSQLユーザ会
yumでPostgreSQLをインストールしてみよう | Let's Postgres
CentOS で PostgreSQL を使ってみよう!(2) | Let's Postgres
ちょっとどころか随分古いけど上記の記事をみながら、psqlが使えるぐらいまでの準備。
まず、インストール。
[bg1@localhost ~]$ su パスワード: [root@localhost bg1]# yum install postgresql-server メタデータの期限切れの最終確認: 3:17:41 時間前の 2020年03月18日 19時34分01秒 に実施しました。 依存関係が解決しました。 ================================================================================ Package Architecture Version Repository Size ================================================================================ インストール: postgresql-server x86_64 11.7-1.fc31 updates 5.2 M 依存関係のインストール: libpq x86_64 12.2-1.fc31 updates 212 k postgresql x86_64 11.7-1.fc31 updates 1.5 M トランザクションの概要 ================================================================================ インストール 3 パッケージ ダウンロードサイズの合計: 6.9 M インストール済みのサイズ: 28 M これでよろしいですか? [y/N]: y パッケージのダウンロード: (1/3): libpq-12.2-1.fc31.x86_64.rpm 57 kB/s | 212 kB 00:03 (2/3): postgresql-11.7-1.fc31.x86_64.rpm 165 kB/s | 1.5 MB 00:09 (3/3): postgresql-server-11.7-1.fc31.x86_64.rpm 159 kB/s | 5.2 MB 00:33 -------------------------------------------------------------------------------- 合計 207 kB/s | 6.9 MB 00:34 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 インストール中 : libpq-12.2-1.fc31.x86_64 1/3 インストール中 : postgresql-11.7-1.fc31.x86_64 2/3 scriptletの実行中: postgresql-server-11.7-1.fc31.x86_64 3/3 インストール中 : postgresql-server-11.7-1.fc31.x86_64 3/3 scriptletの実行中: postgresql-server-11.7-1.fc31.x86_64 3/3 検証 : libpq-12.2-1.fc31.x86_64 1/3 検証 : postgresql-11.7-1.fc31.x86_64 2/3 検証 : postgresql-server-11.7-1.fc31.x86_64 3/3 インストール済み: postgresql-server-11.7-1.fc31.x86_64 libpq-12.2-1.fc31.x86_64 postgresql-11.7-1.fc31.x86_64 完了しました! [root@localhost bg1]#
postgresユーザができてるか確認。
[root@localhost bg1]# less /etc/passwd [root@localhost bg1]# id postgres uid=26(postgres) gid=26(postgres) groups=26(postgres) [root@localhost bg1]#
いた。
fingerでも、
[root@localhost bg1]# finger postgres bash: finger: コマンドが見つかりませんでした... コマンド finger' を提供するためにパッケージ 'finger' をインストールしますか? [N/y] y * キューで待機中... * パッケージの一覧をロード中。... 以下のパッケージはインストールされるべきものです: finger-0.17-65.fc31.x86_64 The finger client 変更したまま継続しますか? [N/y] y * キューで待機中... * 認証を待ち受け中... * キューで待機中... * パッケージをダウンロード中... * データを要求中... * 変更をテスト中... * パッケージのインストール中... Login: postgres Name: PostgreSQL Server Directory: /var/lib/pgsql Shell: /bin/bash Never logged in. No mail. No Plan.
finger入ってなかったのかな。よくわからん。
[root@localhost bg1]# useradd testuser1 [root@localhost bg1]# passwd testuser1 ユーザー testuser1 のパスワードを変更。 新しいパスワード: 新しいパスワードを再入力してください: passwd: すべての認証トークンが正しく更新できました。
postgresとは別にtestuser1を追加。
サービス起動に失敗。
initdbが先に必要らしい。
[root@localhost bg1]# postgresql-setup initdb WARNING: using obsoleted argument syntax, try --help WARNING: arguments transformed to: postgresql-setup --initdb --unit postgresql * Initializing database in '/var/lib/pgsql/data' * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log [root@localhost bg1]#
これで、
今度は成功した。
[root@localhost bg1]# su - postgres [postgres@localhost ~]$
postgresユーザに切り替え。
[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 (3 行) [postgres@localhost ~]$
-lオプションでDB一覧表示。
[postgres@localhost ~]$ psql postgres psql (11.7) "help" でヘルプを表示します。 postgres=# \dt リレーションが見つかりませんでした。 postgres=# exit [postgres@localhost ~]$
postgresデータベース中身あらず。
[postgres@localhost ~]$ psql template0 psql: FATAL: 現在データベース"template0"は接続を受け付けません [postgres@localhost ~]$
template0データベースは接続できず。
[postgres@localhost ~]$ psql template1 psql (11.7) "help" でヘルプを表示します。 template1=# \dt リレーションが見つかりませんでした。 template1=# exit [postgres@localhost ~]$
template1データベース中身あらず。