How to Fix “An old version of the database format was found” While Starting PostgreSQL

I would like to share with you on how to fix “An old version of the database format was found” While Starting PostgreSQL server. This error usually happen after we upgrade the postgresql from the lower version to higher version. As an example, we upgrade the postgresql version 8.2 to postgresql version 8.4.1 as below. You will get an error while you starting the postgresql.

This error will appeared when starting the postgresql service

    [root@server ~]# service postgresql start
    An old version of the database format was found.
    You need to upgrade the data format before using PostgreSQL.
    See /usr/share/doc/postgresql-8.4.1/README.rpm-dist for more information.

1. Assume that you have successfully backup the postgresql database.
2. Run this command.

    [root@server ~]# cd /var/lib/pgsql/data
    [root@server data]# ls
    base    pg_clog      pg_ident.conf  pg_multixact  pg_tblspc    PG_VERSION  postgresql.conf
    global  pg_hba.conf  pg_log         pg_subtrans   pg_twophase  pg_xlog     postmaster.opts
    [root@server data]# rm -rf *

Reinitialize the database.

    [root@server data]# service postgresql initdb
    Initializing database:                                     [  OK  ]

or you can proceed to directly start the database service.

    [root@server data]# service postgresql start
    Starting postgresql service:                               [  OK  ]
  1. Erming Pei
    Erming Pei
    July 4, 2011 at 10:18 am


    Recently I encountered the same problem when upgraded postgresql from 8.2 to 8.4.
    Nice to see your fix solution. It seems that you destroy the database at first and then reinitialize it. My question is, after all the steps you offered, what should we do to recover the original database?



  2. Graham
    January 31, 2012 at 10:59 am

    Might want to take a look at the rm command. rm -rf * is dangerous if running as root!

Leave a Reply

Your email address will not be published. Required fields are marked *

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.


* up to 30 days money back guarantee