在Ubuntu12.04上安装postgresql9.1和postgis1.5

来源:互联网 发布:北京国家会计学院知乎 编辑:程序博客网 时间:2024/03/28 16:49

安装postgresql

[plain] view plaincopy
  1. sudo apt-get install postgresql-9.1 postgresql-contrib-9.1  

其中postgresql-contrib-9.1不是必须要安装的,如果不安装,以后使用pgadmin打开数据库时可能会提示安装以使用啥啥啥功能。嫌麻烦的话就一起安装了吧。

如果要安装其他版本的postgresql,可以用

[plain] view plaincopy
  1. sudo apt-cache search postgresql  

查询


安装postgis

[plain] view plaincopy
  1. sudo apt-get install postgresql-9.1-postgis  

该安装的都安装上了, postgresql已经可以使用,如果要建立一个postgis数据库,还要进行下列步骤:


生成postgis模板库

切换到postgres用户

[plain] view plaincopy
  1. sudo su postgres  

新建库postgis_template

[plain] view plaincopy
  1. createdb postgis_template  

执行postgis脚本,这些脚本默认在/usr/share/postgresql/9.1/contrib/postgis-1.5下

[plain] view plaincopy
  1. psql -d postgis_template -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql  
  2. psql -d postgis_template -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql   


修改用户密码

[plain] view plaincopy
  1. psql  
  2. ALTER USER postgres WITH PASSWORD '111111';  



http://blog.csdn.net/wildghost/article/details/7746204