linux
ssh登陆远程服务器
ssh 192.168.31.109 -l root -p 22
新建用户
create user test02 password '123';
授予权限,如授予select权限
grant select on all tables in schema public to test02;
新建数据库表空间
mkdir /usr/local/pgdata
chown postgres:postgres /usr/local/pgdata/
postgres=# create tablespace tbs_test owner postgres location '/usr/local/pgdata';
新建数据库
CREATE database test_db with owner=test02 template=template0 encoding='UTF8' tablespace=tbs_test connection limit = 100;
修改表空间位置
ALTER DATABASE "test_db" SET TABLESPACE "tbs_test02";