Postgresql unable to start

configurationdatabasepostgresqlubuntu-11.10

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.

Best Answer

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.