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.

Symptoms:
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.
    

Solution:
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  ]
    

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

  1. Hi,

    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?

    Thanks,

    Erming

Leave a Reply

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