centos7 安裝postgres9.4

一、安裝postgres資源:
> yum install https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-2.noarch.rpmsql

二、安裝postgresql:
> yum install postgresql94-server數據庫

三、切換到postgres用戶下:centos

> su - postgres
> initdb /var/lib/pgsql/9.4/data編輯器

四、啓動:
> ./postgres -D /var/lib/pgsql/9.4/data(./pg_ctl -D /var/lib/pgsql/9.4/data -l /var/lib/pgsql/9.4/data/server.log start)post

五、進入到postgres用戶下,修改當前用戶的密碼:
> \password 「密碼」spa

六、建立新用戶
> create user "isochrone" with password "isochrone" nocreatedb;
七、建立數據庫,並賦給新建立的用戶
> create database "isochrone" with owner ="isochrone」;
八、將數據庫權限賦給用戶
>grant all privileges on database isochrone to isochrone;
九、使用新增用戶登陸
> psql -U isochrone -d isochrone -h 127.0.0.1 -p 5432 postgresql

十、啓動命令code

/usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/dataserver

安裝postgis(支持經緯度type)blog

 1 yum install -y epel-release
 2 yum search postgis
 3 yum install postgis22_94.x86_64
 4 
 5 登陸postgres帳戶:
 6 # psql
 7 切換到出具庫:
 8 > \c testdb;
 9 添加擴展:
10 > CREATE EXTENSION Postgis;

 

設置全部ip能夠訪問:

1 修改/var/lib/pgsql/9.4/data/postgresql.conf文件;
2 listen_addresses=‘localhost’ 爲 listen_addresses=‘*3 修改/var/lib/pgsql/9.4/data/pg_hba.conf文件:
4 在文件最後添加:host all all 0.0.0.0 0.0.0.0 md5

 

附經常使用指令:

 1 \password:設置當前登陸用戶的密碼
 2 \h:查看SQL命令的解釋,好比\h select 3 \?:查看psql命令列表。
 4 \l:列出全部數據庫。
 5 \c [database_name]:鏈接其餘數據庫。
 6 \d:列出當前數據庫的全部表格。
 7 \d [table_name]:列出某一張表格的結構。
 8 \du:列出全部用戶。
 9 \e:打開文本編輯器。
10 \conninfo:列出當前數據庫和鏈接的信息。
11 \password [user]: 修改用戶密碼
12 \q:退出
相關文章
相關標籤/搜索