createdbは、新しいデータベースを作成する。
こちらは、またPostgreSQLクライアントアプリケーションのラッパーコマンド。
CentOS で PostgreSQL を使ってみよう!(2) | Let's Postgres
ここにあるように、postgresユーザから、testuser1名義でデータベースを作ってみる。
[postgres@localhost ~]$ createdb testuser1db -U testuser1 createdb: データベース template1 に接続できませんでした: FATAL: ユーザ "testuser1" で対向(peer)認証に失敗しました [postgres@localhost ~]$
"FATAL: Ident authentication failed"とは違う気がするが、とにかく失敗する。
Linuxユーザのtestuser1になってから、もう一度実行。
[postgres@localhost ~]$ exit ログアウト [root@localhost bg1]# su - testuser1 [testuser1@localhost ~]$ createdb testuser1db [testuser1@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 testuser1db | testuser1 | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | (4 行) [testuser1@localhost ~]$
今度は作成できた。