3

I want to set up the psql terminal tool in Centos 6.6

I have been given access to as database and i just want to use the terminal for writing queries to the database for information. I have no prior experience with psql before but I want to move on from the pgadmin3 gui.

I started off by installing psql:

yum install postgresql

but when I try to access it, ie. typing [root@localhost]# psql I get the following error:

psql: FATAL:  database "root" does not exist

I've tried using:

psql --host=<DB instance endpoint> --port=<port> --username=<master user name> --password --dbname=<database name>

but that fails to work too, maybe this is really basic but im completely lost for setting this up

johnfk3
  • 469
  • 2
  • 5
  • 15

1 Answers1

10

Use:

psql -U my_pgadmin_username postgres

or

psql -U my_pgadmin_username -h localhost postgres

Alternately, more typical usage:

sudo -u postgres psql
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • So i can access it when i type: psql -d 'DBNAME' -h 'HOSTNAME' -p PORT -U 'USERNAME', but i cant query it at all, it just accepts my commands and returns nothing – johnfk3 Nov 25 '15 at 10:58