facebook twitter youtube facebook facebook facebook

E-Mail : info@askmlabs.com

Phone : +1.215.353.8306

Home » » How to connect to Postgre database

How to connect to Postgre database

Written By askMLabs on Friday, February 21, 2014 | 5:59 AM

In this article, i am going to show you the steps to connect to the postgre database.

First you need to know the port on which postgresql is running. To know this use the following command ..

grep -i  postgresql  /etc/services

The output from the above command lists you the port the postgre is using. Now use the following command to connect to the postgre.

Assuming you installed your postgre with user "postgres" and the port used by postgre is 5432. Now switch user to  postgres and connect to it.

[root@askmlabstools pgsql]# su postgres
bash-4.1$ psql -p5432 -dpostgres
psql (8.4.18)
Type "help" for help.
postgres=# select name,setting from pg_settings where name='post';
 name | setting
------+---------
(0 rows)
postgres=# select name,setting from pg_settings where name='poRT';
 name | setting
------+---------
(0 rows)
postgres=# select name,setting from pg_settings where name='port';
 name | setting
------+---------
 port | 5432
(1 row)
postgres=# select * from pg_user;
 usename  | usesysid | usecreatedb | usesuper | usecatupd |  passwd  | valuntil | useconfig
----------+----------+-------------+----------+-----------+----------+----------+-----------
 postgres |       10 | t           | t        | t         | ******** |          |
 nagiosxi |    16384 | f           | f        | f         | ******** |          |
(2 rows)
postgres=# exit
postgres-# \q

Hope it help.
SRI


Share this article :

Related Articles By Category



Post a Comment

Thank you for visiting our site and leaving your valuable comment.

 
Support :
Copyright © 2013. askMLabs - All Rights Reserved
Proudly powered by Blogger