Postgresql 9.2 pg_dump version mismatch

I encountered this while using Heroku on Ubuntu, and here's how I fixed it:

  1. Add the PostgreSQL apt repository as described at "Linux downloads (Ubuntu) ". (There are similar pages for other operating systems.)

  2. Upgrade to the latest version (9.3 for me) with:

    sudo apt-get install postgresql
    
  3. Recreate the symbolic link in /usr/bin with:

    sudo ln -s /usr/lib/postgresql/9.3/bin/pg_dump /usr/bin/pg_dump --force
    

    The version number in the /usr/lib/postgresql/... path above should match the server version number in the error you received. So if your error says, pg_dump: server version: 9.9, then link to /usr/lib/postgresql/9.9/....


  1. Check the installed version(s) of pg_dump:

    find / -name pg_dump -type f 2>/dev/null
    
  2. My output was:

    /usr/pgsql-9.3/bin/pg_dump
    /usr/bin/pg_dump
    
  3. There are two versions installed. To update pg_dump with the newer version:

    sudo ln -s /usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump --force
    

This will create the symlink to the newer version.