You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

---
layout: post
title: "psql FATAL: database files are incompatible with server"
author:
display_name: sipp11
login: sipp11
email: sipp11@gmail.com
url: ''
author_login: sipp11
author_email: sipp11@gmail.com
date: Jan 23, 2015
tags:
- postgres
- error
---
Once in a while you might see this error.
LOG: skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.0.
### Why?
Basically it meant that you somehow upgraded postgresql server. All your data was safe, yet it would never work with new server until you upgraded the data.
### Solution
1. Figure out what version both old and new one are. As example above, older is 9.3 and 9.4 for new one.
2. Move your existing data to another directory
$ mv /usr/local/var/postgres /usr/local/var/postgres9351
3. Initial a new database for the new `postgresql`
$ initdb /usr/local/var/postgres -E utf8
4. Upgrade the old one to current one with `pg_upgrade` command; for more information you could check out at [postgresql docs](http://www.postgresql.org/docs/9.2/static/pgupgrade.html)
$ pg_upgrade -b /usr/local/Cellar/postgresql/9.3.5_1/bin -B /usr/local/Cellar/postgresql/9.4.0/bin -d /usr/local/var/postgres9351 -D /usr/local/var/postgres
it was actually simple than it looks with clearer explanation as following:
$ pg_upgrade -b oldbindir -B newbindir -d olddatadir -D newdatadir
5. Start your postgresql server and continue working!