# tar -zxvf postgresql-9.6.2.tar.gz
# cd postgresql-9.6.2
# yum install flex bison
# ./configure --with-libxml --with-ossp-uuid --with-libs=/opt/postgresql/9.6/lib --with-includes=/opt/postgresql/9.6include
报错需要安装readline,那就把readline和readline-devel都装上
# make# make install
#### 把 PATH=$PATH:$HOME/bin 改成下面内容 ####
# PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin# source .bash_profile
# adduser postgres
# vi /etc/passwd
#### 把 postgres:x:528:528::/home/postgres:/bin/bash 改成下面内容 ####
# postgres:x:528:528::/opt/postgresql/9.6:/bin/bash
#### 将.bash_profile 移动到新的用户目录并修改权限 ##### cp /home/postgres/.bash_profile /opt/postgresql/9.6
# chown postgres.postgres .bash_profile
#### 删除用户目录 ##### rm -rf postgres/
# mkdir /data/postgresql/
# chown postgres /data/postgresql/
# su - postgres
# exit
# cd cd postgresql-9.6.2
# cp contrib/start-scripts/linux /etc/init.d/postgresql
# vim /etc/init.d/postgresql#### prefix=/usr/local/pgsql 改成以下内容 ###
prefix=/opt/postgresql/9.6#### PGDATA="/usr/local/pgsql/data" 改成以下内容 ###
PGDATA="/data/postgresql/"
# chmod +x /etc/init.d/postgresql
# service postgresql restart
# chkconfig --add postgresql
# chkconfig postgresql on
# su - postgres
postgres=# CREATE EXTENSION "uuid-ossp";# /usr/local/pgsql/data
postgresql默认只允许本机访问,需要远程连接、外网访问,如何配置? 先配置监听地址# vi /usr/local/pgsql/data/postgresql.conf
#### 取消掉下面一行的前面的#注释,并将值改为* ####
# listen_addresses = '*'
再配置支持远程连接# make && make install