版本信息

ubuntu    14.04.1LTS

postgresql   9.3.5

postgis       2.1.2

今天尝试着安装了postgis 2.1.2,(较简便的包安装,不是源码安装)把步骤写出来分享给大家

1.安装postgresql

首先用  apt-cachesearch postgresql 查找最新的软件包,结果如下

postgresql-9.3 - object-relational SQLdatabase, version 9.3 server

postgresql-9.3-dbg - debug symbols forpostgresql-9.3

postgresql-client-9.3 - front-end programsfor PostgreSQL 9.3

postgresql-contrib-9.3 - additionalfacilities for PostgreSQL

postgresql-9.3-debversion - Debian versionnumber type for PostgreSQL

postgresql-9.3-ip4r - IPv4 and IPv6 typesfor PostgreSQL 9.3

postgresql-9.3-orafce - Oracle supportfunctions for PostgreSQL 9.3

postgresql-9.3-pgfincore - set ofPostgreSQL functions to manage blocks in memory

安装第一个

apt-getinstall postgresql-9.3

2.安装postgis

首先用apt-cachesearch postgresql postgis查找最新的版本

apt-getinstall postgresql-9.3-postgis-2.1

注意这个包只是postgis的包并不包含postgresql 它的含义是适合postgresql 9.3的postgis 2.1版本

3.登录postgresql

在下载postgresql时,自动就会创建一个postgresql用户,可以用这个用户登录

$ sudo -s -u postgres
postgres$ psql
psql (9.1.3)
Type "help" for help.

如果想要创建自己的用户(如创建自己的用户hadoop)登录,可以这样

$USER$ sudo -s -u postgres
postgres$ createuser --superuser $USER ---- note: createuser is a command line tool to create a PostgreSQL user, not a system account
postgres$ createdb $USER
postgres$ psql
psql (9.1.3)
Type "help" for help.

postgres=# \password $USER
Enter new password:
Enter it again:
postgres=# \q
postgres$ exit
$USER$ psql
psql (9.1.3)
Type "help" for help. $USER=#

postgres@ubuntu:~$ createuser --superuser hadoop

postgres@ubuntu:~$ createdb hadoop

postgres@ubuntu:~$ psql

psql (9.3.5)

Type "help" for help.

postgres=# \password hadoop

Enter new password: 

Enter it again: 

postgres=# \q

postgres@ubuntu:~$ su hadoop

Password: 

hadoop@ubuntu:~$ psql

psql (9.3.5)

Type "help" for help.

4.连接postgresql与postgis(赋予postgresql空间数据库的能力)

hadoop=# CREATE EXTENSION postgis;

CREATE EXTENSION

hadoop=# CREATE EXTENSION postgis_topology;(支持拓扑)

CREATE EXTENSION

5.大功告成,现在开始测试功能

首先测试一下版本信息

hadoop=# SELECT version();//显示postgresql的版本

hadoop=# SELECT postgis_full_version();//显示postgis的版本

然后创建一个点

hadoop=# SELECT ST_Point(1, 2) AS MyFirstPoint;

结果为

                myfirstpoint                

--------------------------------------------

 0101000000000000000000F03F0000000000000040

(1 row)

postgres=# \q(\q为退出)



主要参考   http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204

ubuntu安装postgresql与postgis的更多相关文章

  1. ubuntu安装postgresql以及pgadmin4当前最新(4.3)网页版

    pgAdmin4安装 1.安装安装包 sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv ...

  2. ubuntu 安装 postgresql

    安装环境: Ubuntu 10.04-desktop-i386 PostgreSQL 8.4 1. 安装PostgreSQL 输入如下命令 sudo apt-get install postgresq ...

  3. ubuntu16.04搭建geodjango+postgresql+postgis的WebGIS框架(二))安装postgresql和postgis

    卸载老版本sudo dpkg --purge postgis postgresql-9.3-postgis1.安装postgresql sudo apt-cache search postgresql ...

  4. CentOS7使用yum安装PostgreSQL和PostGIS

    更新yum源 CentOS7默认yum源的PostgreSQL版本过低,不适合在本版本上使用.在https://yum.postgresql.org/repopackages.php上找到适合Cent ...

  5. centos7安装postgresql和postgis

    1.安装步骤 -- 安装对应的rpm文件(其他系统的rpm包,请自行到https://yum.postgresql.org/下载)yum install -y https://download.pos ...

  6. Ubuntu 安装PostgreSQL

    安装最新版: sudo apt-get install postgresql 安装完成后,默认会: (1)创建名为"postgres"的Linux用户 (2)创建名为"p ...

  7. Ubuntu安装PostgreSQl

    warrior@pc:~$ sudo apt-get install postgresql-xx-xx #可以使用Tab键进行代码补全 warrior@pc:~$ sudo su postgres # ...

  8. ubuntu下postgreSQL安装配置

    一.安装并配置,并设置远程登陆的用户名和密码 1.安装postgreSQL sudo apt-get update sudo apt-get install postgresql-9.4 在Ubunt ...

  9. Ubuntu下postgresql安装

    第一步:在Ubuntu下安装Postgresql         1.使用 apt-get install 安装          zhang@ubuntu:~/protgresql#sudo apt ...

随机推荐

  1. hive搭建配置

    下载cd /data0/software/hivewget http://mirror.bit.edu.cn/apache/hive/hive-0.12.0/hive-0.12.0-bin.tar.g ...

  2. 利用Shell命令获取IP地址

    一 :获取单个网卡的IPv4地址,方法如下: 方法一:$/sbin/ifconfig ethX | awk '/inet addr/ {print $2}' | cut -f2 -d ":& ...

  3. 【Search for a Range】cpp

    题目: Given a sorted array of integers, find the starting and ending position of a given target value. ...

  4. IOS 打包后安装崩溃,debug正常运行

    今天遇到个奇葩问题,archive后的包安装后有一个crash,必崩的.但是调试跟踪时是好的. 为了方便调试,使用了release模式,这样不用每次都archive后安装进行测试.由于没法运行时deb ...

  5. HDU 5568 sequence2 区间dp+大数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5568 题意: 求所有长度为k的严格升序子序列的个数. 题解: 令dp[i][k]表示以i结尾的长度为 ...

  6. boost之function

    boost中function是对函数指针和函数对象的进行封装的模板类. 定义示例:function<int()> func生成一个空的对象,表示函数参数个数为零,返回类型为int. #in ...

  7. poj 2449 Remmarguts' Date K短路+A*

    题目链接:http://poj.org/problem?id=2449 "Good man never makes girls wait or breaks an appointment!& ...

  8. 【BZOJ】【1021】【SHOI2008】Dept循环的债务

    DP 去膜拜题解了>_>玛雅原来是动规…… 让我先理解一下为什么要用动规:这个题根据钱数推方案其实是无从下手的……(线性规划?……事实证明我想多了) 啦-我们先来看个超级简化版的问题:怎么 ...

  9. linux系统非ROOT用户80端口不能启动tomcat问题的变通办法——通过Iptables端口转发

    2010-07-17 13:21:42 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRule]{ ...

  10. matrix_2015_1 138 - ZOJ Monthly, January 2015

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3844 第一个,n个数,每次操作最大数和最小数都变成他们的差值,最后n个数相 ...