PostgreSQL数据库的安装与PostGIS的安装(转)

原文:http://lovewinner.iteye.com/blog/1490915

安装postgresql

 

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

 

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

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

 

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

 

查询

 

安装postgis

 

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

 

 

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

 

 

生成postgis模板库

切换到postgres用户

 

[plain] view plain copy
 
  1. sudo su postgres  

 

新建库postgis_template

 

[plain] view plain copy
 
  1. createdb postgis_template  

 

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

 

[plain] view plain copy
 
  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 plain copy
 
  1. psql  
  2. ALTER USER postgres WITH PASSWORD '111111';  

 

 
 
posted @ 2016-04-19 01:16  奋斗终生  Views(1886)  Comments(0Edit  收藏  举报