Installing PostgreSQL 9.6 on Centos 7
Installing PostgreSQL
Add PostgreSQL repository and update
[[email protected] ~]# yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
[[email protected] ~]# yum update
Install PostgreSQL 9.6
[[email protected] ~]# yum install postgresql96 postgresql96-server postgresql96-lib
We initialize
[[email protected] ~]# /usr/pgsql-9.6/bin/postgresql96-setup initdb
Add PostgreSQL to autoload and run it
[[email protected] ~]# systemctl enable postgresql-9.6
[[email protected] ~]# systemctl start postgresql-9.6
PostgreSQL setup
We open access to Postgresql, for this we edit in the file postgresql.conf string listen_addresses
[[email protected] ~]# nano /var/lib/pgsql/9.6/data/postgresql.conf
listen_addresses="*"
We allow connecting to PostgreSQL from the specified ip-addresses, for this we edit the pg_hba.conf file
[[email protected] ~]# nano /var/lib/pgsql/9.6/data/pg_hba.conf
host all all %ip%/32 md5
Restarting PostgreSQL
[[email protected] ~]# systemctl restart postgresql-9.6
Open port 5432 in the firewall
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=5432/tcp
success
[[email protected] ~]# firewall-cmd --reload
success
We put a password on the postgres user
[[email protected] ~]# su - postgres
bash-4.2$ psql
psql (9.4.4)
Type "help" for help.
postgres=# password
Enter new password: postgres
Enter it again: postgres
postgres=# q
exit