Postgresql 9 - psql: could not connect to server: No such file or directory

I have just installed PostgreSQL 9.0.4 on my local machine (ubuntu 10.10), after removing 8.4. Now I want to import a database that is so large that the import in Pgadmin crashes. So I need psql to do this, but when I try, I get the following error:

psql: could not connect to server: No such file or directory
      Is the server running locally and accepting
      connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

The server seems to be running though, as I can open Pgadmin, create a database, etc. So I wonder if this is different from 8.4? How can I get this working?
LVL 13
Who is Participating?

Do you know how you configured pgadmin to access the database? You can try to use same configuration for psql. e.g.

psql -hlocalhost -Uusername  database name

If you don't know the username/password,

You can run "ps -elf | grep postmaster" to find out the postgres database process. it should be somthing like

/usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data

Then you need to goto /var/lib/pgsql/data/ folder, modify pg_hba.conf, the reload the postgresql configuration.

for example, add
host    all         root  trust

in pg_hba.conf file, then reload the configuration by "/etc/init.d/postgresql reload"

Then you can login by "psql -hlocalhost database" as root

R7AFAuthor Commented:

psql -hlocalhost -Upostgres
psql -hlocalhost -Upostgres  database_name

(At first I read it like "database" was a parameter name, with the space inbetween database and name.)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.