Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




27.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

                 [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++

  • The rm command will remove all the source files we have used to compile and install PostgreSQL. It will also remove the PostgreSQL compressed archive from the /var/tmp directory.

  • The rpm -e command will remove the egcs-c++ package we installed to compile the PosgreSQL Server. Note that the egcs-c++ package is required only for compiling programs like PostgreSQL and can be uninstalled safely after successful compilation of PostgreSQL.

  Published under the terms of the Open Publication License Design by Interspire