Friday, June 17, 2016

pg_dump version mismatch - How to fix in CentOS 7

If you've encountered with this issue:

pg_dump: server version: 9.4.7; pg_dump version: 9.2.15
pg_dump: aborting because of server version mismatch

Then it means that the version on your local pg_dump tool is older that the version of the remote postgresql database.

In my case I had postgresql 9.2 running on CentOS 7 and I was trying to dump database out of remote postgresql 9.4. So the solution was to install 9.4 using postgresql repository instead of centos distro repository. Below you will find instructions that you need to do in order to fix this issue on CentOS.

1. Navigate to this link and choose necessary rpm:
http://yum.postgresql.org/repopackages.php#pg94

2. Install rpm
sudo rpm -Uvh https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-2.noarch.rpm

3. Install 9.4:
sudo yum install postgresql94

4. Find necessary pg_dump location:
find / -name pg_dump -type f 2>/dev/null

5. Run newly installed pg_dump:
/usr/pgsql-9.4/bin/pg_dump -h {dbhost} -U {dbuser} {dbname} > {dbname}.sql

That's it :-D