创建 PostgreSQL 用户和数据库

简化 SQL 语句, 注意高版本的 PostgreSQL 需要使用 GRANT 命令

1
2
3
4
5
6
7
8
9
10

create role foo with login password 'yourpassword' valid until 'infinity';

-- 高版本需要使用这个命令
GRANT foo TO postgres;

create database bar with encoding='UTF8' owner=foo connection limit=-1;

REVOKE foo FROM postgres;

Reference:

  1. ubuntu下postgreSQL安装配置
  2. Backup&Restore