新規に作成したユーザーで、新規に作成したスキーマを利用したいと思っているのですが、上手くいきません。
簡単に言うと、CREATE ROLE test_user WITH LOGIN PASSWORD 'test';
とCREATE SCHEMA test_schema;
を実行し、test_user
からtest_schema
を利用できるようにしたいのですが、所有者や権限などを設定しても、test_user
からtest_schema
が見えません。
インストールから、手順を書いてみます。
# yumでインストール [root@localhost ~]# yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm [root@localhost ~]# yum install postgresql11 [root@localhost ~]# yum install postgresql11-server # 初期データベースを作成。 [root@localhost ~]# PGSETUP_INITDB_OPTIONS="-E UTF8 --locale=C" /usr/pgsql-11/bin/postgresql-11-setup initdb # 起動および自動起動設定 [root@localhost ~]# systemctl start postgresql-11.service [root@localhost ~]# systemctl enable postgresql-11.service # postgresユーザーに切り替え [root@localhost ~]# su - postgres -bash-4.2$ psql -U postgres # ユーザー作成 postgres=# CREATE ROLE test_user WITH LOGIN PASSWORD 'test'; postgres=# alter role test_user with superuser; postgres=# CREATE DATABASE test_db; # スキーマを作成して、そのスキーマの所有者を↑の新規作成ユーザーに変更 postgres=# CREATE SCHEMA test_schema; postgres=# ALTER SCHEMA test_schema OWNER TO test_user; postgres=# GRANT USAGE ON SCHEMA test_schema TO test_user; postgres=# GRANT all ON SCHEMA test_schema TO test_user;
ここまで実施して、test_user
でtest_schema
にテーブルを作成しようと思ったのですが、以下のようにスキーマを確認しようとすると、なぜか表示されません。
[root@localhost ~]# psql -U test_user -d test_db ユーザ test_user のパスワード: psql (11.1) "help" でヘルプを表示します。 test_db=# test_db=# \dn スキーマ一覧 名前 | 所有者 --------+---------- public | postgres (1 行) test_db=#
所有者に設定し、さらに権限も付与していると思うのですが、他に必要な作業がありますでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。