linunx(ubuntu)安裝postgresql並添加postgis支持

本文只介紹postgresql的安裝及添加postgis支持,安裝過程缺少的依賴根據需要安裝(根據報錯搜索下載安裝)《@中國人叔叔-lt》
本文postgresql9.1更高版本可能有更好的方式添加postgis支持

第一步、如果不自己下載安裝文件,ubuntu提供命令下載安裝

  1. 查看apt-get庫中的軟件版本支持 :sudo apt-cache search postgresql
  2. 安裝:sudo apt-get install postgresql-9.1

第二步、安裝postgis

  1. 查看apt-get庫中的軟件版本支持 :sudo apt-cache search postgis
  2. 安裝:sudo apt-get install postgis

第三步、用戶、密碼及數據庫創建與修改

修改PostgreSQL數據庫默認用戶postgres的密碼

PostgreSQL數據庫創建一個postgres用戶作爲數據庫的管理員,密碼隨機,所以需要修改密碼,方式如下:

步驟一:登錄PostgreSQL:

sudo -u postgres psql

步驟二:修改登錄PostgreSQL密碼:
alter user postgres with password 'postgres';

修改linux系統postgres用戶的密碼

PostgreSQL會創建一個默認的linux用戶postgres,修改該用戶密碼的方法如下:
步驟一:刪除用戶postgres的密碼

sudo  passwd -d postgres 
步驟二:設置用戶postgres的密碼
sudo -u postgres passwd  
系統提示輸入新的密碼
Enter new UNIX password: 

Retype new UNIX password: 

passwd: password updated successfully

第四步、創建數據庫並添加postgis支持

進入postgres用戶

sudo su postgres  
創建名爲ltpostgis 數據庫 自己取名
createdb ltpostgis 
執行postgis腳本,這些腳本默認在/usr/share/postgresql/9.1/contrib/postgis-1.5下 ,執行後ltpostgis 就有postgis支持了
psql -d ltpostgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql  
psql -d ltpostgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章