0

postgresql log file:

 * Starting PostgreSQL 9.1 database server * The PostgreSQL server failed to start. Please check the log output: 2012-02-24 04:26:07 GMT FATAL: "/var/lib/postgresql/9.1/main" is not a valid data directory 2012-02-24 04:26:07 GMT DETAIL: File "/var/lib/postgresql/9.1/main/PG_VERSION" does not contain valid data. 2012-02-24 04:26:07 GMT HINT: You might need to initdb. 

this happened when my ubuntu oneiric crashed. What to do now? Thank you.

1
  • 1
    Well....did you look at the directory and file mentioned in the error messages? Commented Feb 24, 2012 at 4:33

1 Answer 1

-1

I had the same problem. This file only contains the version of postgreql, so it should contain '9.1'.

So just try:

echo 9.1 > "/var/lib/postgresql/9.1/main/PG_VERSION" 

and start the DB server again with:

service postgresql start 

Have fun, MBR.

1
  • 2
    This suggestion can be VERY DANGEROUS: A machine which had enough filesystem damage to break Postgres to the point where it won't start needs more attention than "Just put the version number in the file and hope it works" - At a bare minimum some time needs to be taken to ensure that the crash did not damage or lose the other DB files. Commented Jun 18, 2013 at 21:52

You must log in to answer this question.