ASN
ASN

Reputation: 1863

how to update pg_dump to server version in Mac OS

I'm trying to backup a local database in my laptop (PostGresSQL 9.6 ,PgAdmin3) and I see the following error.

pg_dump: server version: 9.6.3; pg_dump version: 9.5.5 pg_dump: aborting because of server version mismatch

I've tried some answers on SO, like updating the postgres on homebrew but it threw an error as well.

Error: postgres not installed

When I checked the contents of postgres application package, I found 2 folders in the versions folder, 9.5 and 9.6. I tried running the pg_dump in the bin folder of both the versions and all I see is this error:

enter image description here

Can someone help me to solve this problem and make a backup of my database

Upvotes: 23

Views: 30887

Answers (5)

YASH GARUDKAR
YASH GARUDKAR

Reputation: 181

I had a version 14 installed. I first attempted to uninstall it and then install the new version and link it.

brew uninstall postgresql
brew install postgresql@16 #I wanted 16 version
brew services start postgresql@16 #start the postgres service
brew link postgresql@16 --force #this will make 16 your default version

Upvotes: 1

J-peace
J-peace

Reputation: 131

MACOS M2 solution:

➜ ~ brew link postgresql@16 --force

if it is already linked, run before: ➜ ~ brew unlink postgresql@14

Upvotes: 10

Jeff Spicoli
Jeff Spicoli

Reputation: 500

Resurfaced when our server got to postgresql 13.8 and locally I was on 12

Uninstall the old postgresql version and install a new one. Start & stop postgres services too. On Mac:

brew install postgresql@13 # install server version or higher
brew services stop postgresql@12 # stop postgres
brew uninstall postgresql@12 # uninstall old version
brew services start postgresql@13 # start newly installed version

Double check the version in use: psql --version

Get info on postgresql versions installed via brew: brew info postgresql@13

Upvotes: 20

Ahmad Hussain
Ahmad Hussain

Reputation: 2491

I found this one more helpful than above. It has upgraded the DB without any issue. https://quaran.to/Upgrade-PostgreSQL-from-12-to-13-with-Homebrew

brew services stop postgresql
brew postgresql-upgrade-database
brew services start postgresql

Upvotes: -2

Lex
Lex

Reputation: 5014

If using brew on MacOS brew install [email protected] Homebrew install specific version of formula?

Stop postgres

brew services stop postgresql

Upgrade with Homebrew

brew update
brew upgrade postgresql

Check Version:

psql --version
> psql (PostgreSQL) 10.3

Upvotes: 5

Related Questions