petere / homebrew-postgresql

🐘 PostgreSQL formulae for the Homebrew package manager
295 stars 34 forks source link

Server version mismatch with Postgresql tools #54

Closed ogirginc closed 4 years ago

ogirginc commented 4 years ago

If this isn't the place to ask, sorry for taking your time! I am getting the error below when I use psql

psql (10.11 (Homebrew petere/postgresql), server 11.6 (Homebrew petere/postgresql))

It wasn't an issue until I tried to use pg_dumpall. When I run

pg_dumpall > ~/Downloads/all_databases.sql

I got the error below:

server version: 11.6 (Homebrew petere/postgresql); pg_dumpall version: 10.11 (Homebrew petere/postgresql)
aborting because of server version mismatch

It's not a deal breaker as I can simply use

/usr/local/Cellar/postgresql@11/11.6/bin/pg_dumpall > ~/Downloads/all_databases.sql

However, my assumption was this shouldn't be a problem at all because, even though I have multiple Postgresql installed, I am only running v11.

$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory                        Log file
11  main    5432 online ogirginc /usr/local/var/lib/postgresql/11/main /usr/local/var/log/postgresql/postgresql-11-main.log

I would like to know if it is possible to force psql or any other Postgresql tool to use the same version as the Postgresql version? Or am I misunderstanding the use of clusters?

Setup

petere commented 4 years ago

The pg_wrapper(1) man page explains how the version of the client program is chosen. Please check how that applies to your situation.

ogirginc commented 4 years ago

From what I have read, PGCLUSTER="12/main" psql should have work but, it didn't. However, I should have been more careful. I was getting a mismatch error for 10.11 but, I haven't installed that version. pg_lsclusters only returns 11 & 12.

Turns out, a couple of years ago, I have exported postgresql@10 to my PATH. It was causing, pg_wrapper to keep using 10.11 because, I had installed postgresql@10 even though no cluster was created.

I have uninstalled postgresql@10 & updated my .zshrc. Now, all works fine.

Thanks for taking time to help! I have learned a lot. 👍