3. Database installation using superuser account

Once PostgreSQL is installed on your Linux server, it's important to create the database installation before starting your PostgreSQL server. To create the database installation, use the following command:

                 [root@deep] /# su postgres
                 [postgres@deep /]$ initdb --pglib=/usr/lib/pgsql --pgdata=/var/lib/pgsql
               

We are initializing the database system with username postgres uid=40. This user will own all the files and must also own the server process.


                 Creating Postgres database system directory /var/lib/pgsql/base

                 Creating template database in /var/lib/pgsql/base/template1

                 Creating global classes in /var/lib/pgsql/base

                 Adding template1 database to pg_database...

                 Vacuuming template1
                 Creating public pg_user view
                 Creating view pg_rules
                 Creating view pg_views
                 Creating view pg_tables
                 Creating view pg_indexes
                 Loading pg_description
               

                 [postgres@deep /]$ chmod 640 /var/lib/pgsql/pg_pwd
                 [postgres@deep /]$ exit
               


                 exit
               

                 [root@deep] /#
               

The --pglib command will specify where the library directory of PostgreSQL resides in the system, and the --pgdata command will specify where the database files must reside for this installation on Linux.

Tip

Do not create the database installation as root! This would be a major security hole.

Please don't foreget to Cleanup later:

                 [root@deep] /# cd /var/tmp
                 [root@deep ]/tmp# rm -rf postgresql-version/ postgresql-version.tar.gz
               

Remove the egcs-c++-version.i386.rpm package to save space.

                 [root@deep] /# rpm -e egcs-c++