使用 postges 用户登录
$ docker exec -it ${容器ID} psql -U postgres
创建用户
CREATE USER test WITH PASSWORD '123456';
创建数据库
CREATE DATABASE test OWNER test;
授权
GRANT ALL PRIVILEGES ON DATABASE test TO test;
GRANT ALL ON DATABASE test TO test;
切换数据库
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".
网友评论