[centos7]postgresql安装、初始化密码、允许远程连接设置

tar xvzf postgresql-9.6.3.tar.gz
cd postgresql-9.6.3
./configure –prefix=/usr/local/pgsql
make
make install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su – postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
#用户postgres启动
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
#设置初始化密码
bin/psql postgres
\password postgres
#密码登录
./psql -h localhost -U postgres -W
#允许外网ip访问
防火墙增加5432端口访问
vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state –state NEW -m tcp –dport 5432 -j ACCEPT
重启iptables
vim postgresql.conf
listen_addresses = ‘*’
vim pg_hba.conf
增加一行规则
host all all 0.0.0.0/0 trust
#查看版本
select VERSION();
PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit

发表评论

邮箱地址不会被公开。 必填项已用*标注