psql and pg_dump version mismatch
13,830
Solution 1
sudo rm /usr/bin/pg_dump
sudo ln -s /usr/lib/postgresql/9.3/bin/pg_dump /usr/bin/pg_dump
Solution 2
If your pg_dump is sym-linked to pg_wrapper, then the best fix is to tell pg_wrapper which version to use.
Append
* * 9.6 localhost:5432 *
to /etc/postgresql-common/user_clusters
, (assuming your postmaster is listening on localhost:5432 of course).
This then fixes the problem for all pg_ commands, doesn't involve breaking anything, and scales nicely for future versions which you may wish to install.
See man pg_wrapper
and man postgresqlrc
for details and other options.
NB This answer is specifically for Debian/Ubuntu, and is most likely applicable when there are two version of pg installed, eg. after an upgrade.
Comments
-
Alex Jones almost 2 years
omnia@ubuntu:~$ psql --version psql (PostgreSQL) 9.3.4 omnia@ubuntu:~$ pg_dump --version pg_dump (PostgreSQL) 9.2.8 omnia@ubuntu:~$ dpkg -l | grep pg ii gnupg 1.4.11-3ubuntu2.5 GNU privacy guard - a free PGP replacement ii gpgv 1.4.11-3ubuntu2.5 GNU privacy guard - signature verification tool ii libgpg-error0 1.10-2ubuntu1 library for common error values and messages in GnuPG components ii libpq5 9.3.4-1.pgdg60+1 PostgreSQL C client library ii pgdg-keyring 2013.2 keyring for apt.postgresql.org ii postgresql-9.2 9.2.8-1.pgdg60+1 object-relational SQL database, version 9.2 server ii postgresql-9.3 9.3.4-1.pgdg60+1 object-relational SQL database, version 9.3 server ii postgresql-client-9.2 9.2.8-1.pgdg60+1 front-end programs for PostgreSQL 9.2 ii postgresql-client-9.3 9.3.4-1.pgdg60+1 front-end programs for PostgreSQL 9.3 ii postgresql-client-common 154.pgdg60+1 manager for multiple PostgreSQL client versions ii postgresql-common 154.pgdg60+1 PostgreSQL database-cluster manager ii python-gnupginterface 0.3.2-9.1ubuntu3 Python interface to GnuPG (GPG) ii unattended-upgrades 0.76ubuntu1 automatic installation of security upgrades ii update-manager-core 1:0.156.14.13 manage release upgrades omnia@ubuntu:~$
Seems I have both installed but pg_dump is stuck in an older version? Weird since both are linked to the same "wrapper":
omnia@ubuntu:~$ readlink /usr/bin/psql ../share/postgresql-common/pg_wrapper omnia@ubuntu:~$ readlink /usr/bin/pg_dump ../share/postgresql-common/pg_wrapper
What am I doing wrong?