Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Feb 24 '12 at 18:42

This question came from our site for professional and enthusiast programmers.

1  
Well....did you look at the directory and file mentioned in the error messages? –  Jack Maney Feb 24 '12 at 4:33
    
Off-topic; belongs on Super User or Server Fault –  Ex Umbris Feb 24 '12 at 7:10

1 Answer 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.

share|improve this answer
    
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. –  voretaq7 Jun 18 '13 at 21:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.