Install PostgresQL Centos 7

PostgreSQL (pronounced ‘post-gres-Q-L’) is a free, open-source object-relational database management system (object-RDBMS), similar to MySQL, and is standards-compliant and extensible. It is commonly used as a back-end for web and mobile applications. PostgreSQL, or ‘Postgres’ as it is nicknamed, adopts the ANSI/ISO SQL standards together, with the revisions.
1. Install PostgreSQL
yum install postgresql.x86_64 postgresql-server
PostgreSQL should now be installed.
2. Configure PostgreSQL
By default, PostgreSQL does not allow password authentication. We will change that by editing its host-based authentication (HBA) configuration.
vi /var/lib/pgsql/data/pg_hba.conf
Then replace “ident” with “md5”, so they look like this:
pg_hba.conf excerpt (updated)
host    all             all               md5
host    all             all             ::1/128                 md5
3. Initialize the database and data directories
postgresql-setup initdb
4. Start PostgreSQL
Configure PostgreSQL to start up upon server boot.
systemctl start postgresql
systemctl enable postgresql
5. Switch to the Default PostgreSQL User
su – postgres
You should be able to login without using password. Now, update your password:
postgres=# ALTER USER postgres with encrypted password ‘NewPassword’;
postgres=# \q
6. If you nead, create new user:
postgres=# createuser –interactive
Enter name of role to add: test
postgres=# createdb test
adduser test
sudo -i -u test
# note:
su – postgres
postgres-# psql
postgres-# \password postgres
Enter new password:
Enter it again:
postgres=# setsebool -P httpd_can_network_connect_db 1