sudo -u postgres psql postgres=# CREATE USER dbuser WITH PASSWORD 'password';
查看所有用户
1
postgres=# \du
更改密码
1 2
postgres=# \password dbuser postgres=# \q
删除用户
1
postgres=# drop user dbuser;
创建数据库
1 2 3 4 5 6
postgres=# CREATE DATABASE exampledb OWNER dbuser; postgres=# GRANT ALL PRIVILEGES ON DATABASE exampledb to dbuser; postgres=# \c exampledb; postgres=# ALTER SCHEMA public OWNER to dbuser; postgres=# GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dbuser; postgres=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dbuser;