下载postgresql9.4.5
https://ftp.postgresql.org/pub/source/v9.4.5/
wget https://ftp.postgresql.org/pub/source/v9.4.5/postgresql-9.4.5.tar.gz
yum install gcc
yum install perl-ExtUtils-Embed
yum install readline readline-devel
yum install zlib-devel
yum install postgresql-plperl
tar -zxvf postgresql-9.4.5.tar.gz
cd postgresql-9.4.5
./configure --prefix=/usr/local/pgsql --with-perl
make
make install
添加系统账户:
useradd postgres
passwd postgres
创建数据目录:
mkdir /usr/local/pgsql/data
chown postgres:postgres /usr/local/pgsql/data/
初始化数据库:
su postgres #切换到postgres用户执行
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
修改配置文件
修改
/usr/local/pgsql/data/postgresql.conf
找到
#listen_addresses = ‘localhost’
修改为
listen_addresses = ‘*’
修改
/usr/local/pgsql/data/pg_hba.conf
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.1.0/24 password
#su postgres
#/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
退出postgres用户
#exit
#ps aux | grep postgres
查看postgres是否真的启动
#/usr/local/pgsql/bin/psql -U postgres postgres