创建用户
CREATE USER davide WITH PASSWORD 'jw8s0F4';
CREATE ROLE admin WITH CREATEDB CREATEROLE;
修改用户密码
ALTER ROLE davide WITH PASSWORD 'hu8jmn3';
ALTER ROLE davide WITH PASSWORD NULL;
创建数据库
CREATE DATABASE sales OWNER salesapp
设置数据库只读权限
create user test_readonly with password 'password';
grant connect on DATABASE test to test_readonly;
grant select on all tables in schema public to test_readonly;
导出导入
pg_dump -F t -h 127.0.0.1 -U postgres dbname > dbname.tar
pg_restore -d dbname dbname.tar
Copy
本条目发布于[2019年2月26日](https://c4ys.com/archives/1697 "09:41")。属于[Database](https://c4ys.com/archives/category/database)分类,被贴了 [PostgreSQL](https://c4ys.com/archives/tag/postgresql) 标签。