Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install and connect to database with psql

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

like image 693
johnfk3 Avatar asked Nov 02 '25 22:11

johnfk3


1 Answers

Use:

psql -U my_pgadmin_username postgres

or

psql -U my_pgadmin_username -h localhost postgres

Alternately, more typical usage:

sudo -u postgres psql
like image 72
Craig Ringer Avatar answered Nov 04 '25 13:11

Craig Ringer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!