Linux系统为centOS7版本,postgresql为10版本
1.安装存储库RPM
sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm
2.安装客户端软件包
sudo yum install postgresql10
3.安装服务器包
sudo yum install postgresql10-server
4.初始化数据库
sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
5.切换到root用户
su root
6.修改postgres用户密码
passwd postgres
7.启动postgresql服务
sudo systemctl start postgresql-10
8. 设置postgresql开机⾃启动
sudo systemctl enable postgresql-10
9.切换到postgres⽤户
sudo su postgres
10.变成unix⻛格命令⾏输⼊ bash-4.2$
psql -U postgres
11.设置postgres⽤户密码
ALTER USER postgres WITH PASSWORD 'xxxxx';
12.postgres=# \q
13.bash-4.2$ exit
14.切换到root用户
sudo su root
15.开启远程访问
vi /var/lib/pgsql/10/data/postgresql.conf
修改" #listen_addresses='localhost' "为" listen_addresses='*' "
16.设置信任远程连接
vi /var/lib/pgsql/10/data/pg_hba.conf
修改为
#IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
17.重启postgresql服务
sudo systemctl stop postgresql-10
sudo systemctl start postgresql-10