参考:http://my.oschina.net/dddpeter/blog/116153
1.创建用户
1 | sudo -s -u postgres |
2 | psql |
3 | postgres # CREATE USER xxxx1 WITH PASSWORD 'xxxx'; |
4 | postgres # CREATE DATABASE xxxx2; |
5 | postgres # GRANT ALL PRIVILEGES ON DATABASE xxxx2 to xxxx1; |
alter user postgres with password 'foobar';3.创建数据库
1 | createdb--encoding=UTF8 --owner=foo --template=template_postgis -Ufoo |
参数: --encoding=UTF8 设置数据库的字符集
--owner=foo 设置数据库的所有者
--tmplate=template_postgis 设置建库的模板,该模板支持空间数据操作
--Ufoo 用foo用户身份建立数据库
4. pgsql 命令行查询所有数据库0
\l 查询所有数据库(l即L的小写)
\l+查询所有数据库并显示详细信息