1

We just upgraded our PostgreSQL servers to v13. We heavily use pg_dump on Ubuntu 18 systems to transfer data between databases. After upgrading the servers, pg_dump would complain about a version mismatch.

Easy enough, I installed the postgres-client-13 from the Apt Postgres repo (http://apt.postgresql.org/pub/repos/ap). pg_dump would still complain about a version mismatch so I uninstalled postgresql-client-11. After that pg_dump would complain that "PostgreSQL version 11 is not installed".

No amount or ordering of reinstalling and removing PostgreSQL clients clears up this error. Can anyone point me in the right direction to solving this issue?

2 Answers 2

3

I just ran into this exact problem myself just now. I'm on Debian 10, although it doesn't seem like there should be anything really different for you, since I also used the PostgreSQL apt repository to upgrade from version 11.

If you run file $(which pg_dump), you should see that it's just actually a symbolic link to /usr/share/postgresql-common/pg_wrapper. It turns out this is just a perl script that calls the appropriate version of the utility, depending on the Postgres versions you have installed.

Since we both did the same thing, I'm going to guess that if you look at your postgresql.conf file, in /etc/postgresql/13/main/, the port is going to be set to 5433 instead of the default 5432. This seems to be the root of the problem.

I simply had to change the port setting back to the usual 5432 and restart the postgres service, and now everything works as expected.

I actually experimented with setting the PGSERVICE, PGHOST, and PGPORT variables via the command-line in the call to createdb and other utilities that call pg_wrapper, but I kept getting a prompt for a password, which is odd, because I was running everything as the postgres user. For now I'm just calling that a mystery to be explored at some later time in the future.

1
  • Great find. It would've taken me a very long time to even think to look at the port being different as being the cause, especially since I wasn't even running the postgres service itself, I just needed pg_dump. Nov 4, 2022 at 19:08
0

In my case, I had postgres-13 installed but package postgresql-14 was still lingering:

$ dpkg -l | grep postgresql-14
rc  postgresql-14                         14.9-0ubuntu0.22.04.1

Once removed (dpkg --purge postgresql-14), pg_dump started working normally again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .