前置
sudo su - postgres // 切换到postgres用户
1、PostgreSQL会在安装阶段默认创建一个超级用户角色和一个database,均是postgres,
a、修改PostgreSQL数据库默认用户postgres的密码
sudo passwd -d postgres //删除用户postgres的密码
sudo -u postgres passwd //设置用户postgres的密码
// 系统提示输入新的密码
New password:
Retype new password:
passwd: password updated successfully
库
PG中可以采用分库的方式,即不同的模块创建不同的库;也可以使用同一个库下创建多个SCHEMA的方式;但一个数据连接只能访问一个库,不能跨库访问,即不同数据库之间不能关联查询,参考:
https://www.postgresql.org/docs/9.6/static/ddl-schemas.html
A PostgreSQL database cluster contains one or more named databases. Users and groups of users are shared across the entire cluster, but no other data is shared across databases. Any given client connection to the server can access only the data in a single database, the one specified in the connection request.
建议采用同一个库下创建不同SCHEMA的方式。