0

Easy points for anyone but me. I am trying to use pg_dump. I am running Mac OSx, postgres.app, 9.2, and I want to back up my db. I tried the other solutions for the same problem, but no success. The postgres.app is running on 5432 as far as I can tell. I ran the command below from a random directory, and from my data directory, no luck.

Command tried:

 $ pg_dump pdbt > pdbt.sql

Error:

pg_dump: [archiver (db)] connection to database "pdbt" failed: could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
user2104778
  • 992
  • 1
  • 14
  • 38
  • Could be an OSX issue (wrong location of built-in unix-domain socket // version kludge). Does `psql pdbt -l` work ? Please try with -h _dirname_ eg `pg_dump -h /tmp/ pdbt > pdbt.sql` – wildplasser Sep 28 '13 at 18:10
  • Running psql pdbt -l gives 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/pgsql_socket/.s.PGSQL.5432"? – user2104778 Sep 28 '13 at 18:11
  • I am however able to use psql by clicking on the postgres.app icon at the top of the desktop and selecting "open psql" – user2104778 Sep 28 '13 at 18:12
  • Seems like you have some old binaries installed (one release of OSX had different buit-in paths for the unix domain socket). Does `psql -h localhost pdbt -l` work? Also: try to check for differnt versions of the binaries (with the wrong one first in the PATH) Related: http://stackoverflow.com/questions/8465508/can-not-connect-to-local-postgresql/8482546#8482546 (psql instead of pg_dump, but probably the same OSX issue) – wildplasser Sep 28 '13 at 18:14
  • psql -h localhost pdbt -l works. Where do I go from here? – user2104778 Sep 28 '13 at 18:21
  • Then `pg_dump -h localhost pdbt` will probably work, too. – wildplasser Sep 28 '13 at 18:22
  • Ok, now I get pg_dump: server version: 9.2.4; pg_dump version: 9.1.9 pg_dump: aborting because of server version mismatch – user2104778 Sep 28 '13 at 18:23
  • Presumably the older version is first in the path. try `find / -name pg_dump -ls` (I expect you'll find more than one) – wildplasser Sep 28 '13 at 18:25
  • what am I looking for in the find results (there is a lot of data)? Also, put your comments into an answer and I will accept it – user2104778 Sep 28 '13 at 18:37

1 Answers1

3
  • Could be an OSX issue (wrong location of built-in unix-domain socket // version kludge). Does psql pdbt -l work ?
  • also try with -h dirname eg pg_dump -h /tmp/ pdbt > pdbt.sql
  • Does psql -h localhost pdbt -l work ?
  • then: pg_dump -h localhost pdbt will probably work, too.
  • To find out of multiple version for pg_dump co-exist, you could try: find / -name pg_dump -ls , after that you can try the various versions using the complete pathname (eg /usr/bin/pg_dump -h localhost or /usr/local/bin/pg_dump -h localhost or whatever find found)
  • Presumably the older(wrong) version is first in the path.

In most cases some OSX installion process left some old binaries installed (one release of OSX had different buit-in paths for the unix domain socket). Also: try to check for differnt versions of the binaries (with the wrong one first in the PATH)

Related: (psql instead of pg_dump, but probably the same OSX issue)

Community
  • 1
  • 1
wildplasser
  • 43,142
  • 8
  • 66
  • 109
  • Assuming that the old version is first in the path, how do I change this? – user2104778 Sep 28 '13 at 20:06
  • Remove it. Or _if you want to be safe_ : rename it (eg: `cd baddirectory; mv -i pg_dump pg_dump.BAD` ) – wildplasser Sep 28 '13 at 23:12
  • It appears to have worked. I renamed the old pg_dump in /usr/local/bin and copied and pasted the updated pg_dump from the postgres.app file to /usr/local/bin. Then I ran pg_dump -h localhost pdbt > pdbt.sql. It is running right now but appears to work. Thank you for holding my incompetent hand through that one. – user2104778 Sep 29 '13 at 04:36