How to Fix “/var/lib/pgsql/data is missing. Use “service postgresql initdb” to initialize the cluster first” Error On Linux CentOS 6.2 Server

Question :
When i typing service postgresql start as root on linux CentOS 6.2 server, i got the following error message :

[root@centos62 ~]# service postgresql start

/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initialize the cluster first.

Answer :

PostgreSQL is a Sophisticated open-source Object-Relational DBMS supporting almost all SQL constructs, including subselects, transactions, and user-defined types. PostgreSQL is a powerful, open source object-relational database system that available for many platforms including Linux, FreeBSD, Solaris, Microsoft Windows and Mac OS X. On Linux CentOS 6.2, you have to type “service postgresql initdb” first before starting postgresql server. Please type the following command :

[root@centos62 ~]# service postgresql initdb
Initializing database:                                     [  OK  ]