ユーザー作成
su postgres $ createuser centos could not change directory to "/root" Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) y Shall the new role be allowed to create more new roles? (y/n) n CREATE ROLE
これで、ユーザ「centos」が使えるようになる
データベース作成
$ createdb CREATE DATABASE
データベースの一覧表示
$ psql -l
        List of databases
   Name    |  Owner   | Encoding 
- ----------+----------+----------
 centos    | centos   | UTF8
 postgres  | postgres | UTF8
 template0 | postgres | UTF8
 template1 | postgres | UTF8
 (4 rows)
sqlコンソール
psql centos-> \c centos You are now connected to database "centos".
centos=> create table test ( centos(> test char(10) centos(> ); CREATE TABLE
権限
特に権限設定をしていないユーザは、各DBのpublicスキーマと自分が所有しているschemaに対して操作が可能。
publicスキーマに対するcreate権限を剥奪する場合
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
とする。 FROM PUBLICのPUBLICは全てのユーザを意味する。
[カテゴリ: データベース > Postgresql]
[通知用URL]
Tweet
最終更新時間:2020年04月22日 22時24分06秒