Install PostgreSQL
Go to the PostgreSQL repository download page, and add the PostgreSQL 9.4 repository depending
upon your server architecture.
For CentOS 6.x 32bit:
rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.41.noarch.rpm
For CentOS 6.x 64bit:
rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.41.noarch.rpm
For CentOS 7 64bit:
rpm
-Uvh
http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.41.noarch.rpm
Then, start postgresql service and make it to start automatically on every reboot.
On CentOS 6.x systems:
service postgresql-9.4 start
chkconfig postgresql-9.4 on
On CentOS 7 systems:
systemctl enable postgresql-9.4
systemctl start postgresql-9.4
Sample Output:
psql (9.4.0)
Type "help" for help.
postgres=#
To exit from posgresql prompt, type \q following by quit to return back to the Terminal.
Create database:
$ createdb mydb
Now, login to the psql prompt, and set password and Grant access to the database mydb for senthil:
$ psql
psql (9.4.0)
Type "help" for help.
postgres=# alter user senthil with encrypted password 'centos';
ALTER ROLE
postgres=# grant all privileges on database mydb to senthil;
GRANT
postgres=#
Enter command:
$ dropdb <database-name>
METHOD
Uncomment both lines, and set the IP address of your postgresql server or set * to listen from all
clients as shown below:
listen_addresses = '*'
port = 5432