使用 postges 用戶登錄
$ docker exec -it ${容器ID} psql -U postgres
創(chuàng)建用戶
CREATE USER test WITH PASSWORD '123456';
創(chuàng)建數(shù)據(jù)庫
CREATE DATABASE test OWNER test;
授權(quán)
GRANT ALL PRIVILEGES ON DATABASE test TO test;
GRANT ALL ON DATABASE test TO test;
切換數(shù)據(jù)庫
postgres=# \c test
You are now connected to database "test" as user "postgres".
安裝擴展
CREATE EXTENSION pgcrypto;
切換用戶
test=# \c - test
You are now connected to database "test" as user "test".