6

Locally, it appears that I have Postgresql 9.2.4 installed. I am guessing based off the last error message I received that I do not have the latest version:

pg_dump: server version: 9.3.1; pg_dump version: 9.2.4
pg_dump: aborting because of server version mismatch

On other posts here, what was told to do was to add the following the the .profile and then run the command:

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
. ~/.profile

which did not work.

2 weeks ago, I installed Postgresql with the simple command:

brew install postgresql

and that gave me the version I currently have. It appears as I don't have the latest version then.

How can I a) upgrade to 9.3.1 (which is what the server version looks to be) or b) do one of these fixes like the one I attempted above which did not work.

I am very new to Postgresql so a step by step would be very helpful for me.

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
user2184718
  • 675
  • 1
  • 12
  • 30

3 Answers3

6
brew upgrade postgresql
brew link --overwrite postgresql
tricksterex
  • 61
  • 1
  • 5
5

Solved by adding this at the end of my ~/.bash_profile ( or ~/.zshrc for zsh)

export PG_DUMP="/Applications/Postgres.app/Contents/Versions/9.6/bin/"
PATH=$PG_DUMP:$PATH

Don't forget to run (for bash shell)

$ source ~/.bash_profile

or (for zsh)

$ source ~/.zshrc

You can check the path of pg_dump by running

$ which pg_dump
 ==> /Applications/Postgres.app/Contents/Versions/9.6/bin//pg_dump
  • MacOS Mojave (10.14.2)
  • Postgres.app (2.1.5)
  • PostgreSQL 9.6
MrP
  • 1,408
  • 18
  • 23
-1

There are upgrade instructions you have to follow between Postgresql 9.2 and 9.3...

  1. launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  2. mv /usr/local/var/postgres /usr/local/var/postgres92
  3. brew update
  4. brew upgrade postgresql
  5. initdb /usr/local/var/postgres -E utf8
  6. pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.1/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres
  7. launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Donovan
  • 15,917
  • 4
  • 22
  • 34
  • I do not have the first file you are speaking about. All I have for homebrew in this folder is a redis file, and when I simply run 'brew upgrade postgresql' it says postgresql-9.2.4 already installed – user2184718 Dec 24 '13 at 15:38
  • Then skip that step and proceed to the others. Use common sense. The main idea is that you have to run the `pg_upgrade` step between the old and new database binaries. – Donovan Dec 24 '13 at 15:39
  • You'll have to upgrade homebrew as well, I'll add the additional step for that. – Donovan Dec 24 '13 at 15:42
  • The asker already runs a 9.3.1 server according to the error message, so all this makes no sense. – Daniel Vérité Dec 24 '13 at 15:51
  • I now have downloaded 9.3.2, great! Step 5 is giving me an error saying the directory exists. – user2184718 Dec 24 '13 at 16:04
  • again, then don't worry about it. Line 7 is the important one. – Donovan Dec 24 '13 at 16:18
  • @DanielVérité Dude, I don't make the rules, I only live with them. This is what you have to do to upgrade PostGresql on OSX. I had to do it too. – Donovan Dec 24 '13 at 16:18
  • The error message says: `pg_dump: server version: 9.3.1`. I'm not saying your instructions to upgrade from 9.2.x are wrong, my point is they don't apply because he's not running 9.2.x. – Daniel Vérité Dec 24 '13 at 16:45
  • reading _between the lines_ here, my understanding is he was _trying_ to upgrade and now he's getting that error. Which is _exactly_ what the OP just asked for in his update. But yes, I understand your original statement @DanielVérité ... I always try to _infer_ what the OP means (of course, I'm not _always_ right). – Donovan Dec 24 '13 at 16:47