initlocation [ --location=altdir | -D altdir ] [ --username=name | -u name ] [ altdir ]
Where in your Unix filesystem do you want alternate databases to go? The top level directory is called the PGDATA directory, so you might want to point your first alternate location at PGDATA2.
Who will be the Unix filesystem owner of this database storage area? The Postgres superuser is a Unix user who owns all files that store the database system and also owns the postmaster and backend processes that access them. Usually, this is the user who should run initlocation and who will thus have ownership of the directories and files.
Note: Only the Unix superuser can create a database system with a different user as the Postgres superuser. Specifying a user other than the Postgres superuser may lead to database security and data integrity problems. Refer to the PostgreSQL Administrator's Guide for more information.
initlocation will create directories in the specified place.
Successful completion.
You do not have filesystem permission to write to the specified directory area.
The username which you have specified is not the Postgres superuser.
Specify the --username command line option.
initlocation creates a new Postgres secondary database storage area. A secondary storage area contains a required tree of directories with the correct file permissions on those directories.
Creating a database storage area consists of creating the directories in which database data might live.
There are two kinds of arguments for initlocation. First, you can specify an environment variable (e.g. PGDATA2). This environment variable should be known to the backend for later use in CREATE DATABASE/WITH LOCATION or createdb -D altdir. However, the backend daemon must have this variable in it's environment for this to succeed. Second, you may be able to specify an explicit absolute path to the top directory of the storage area. However,this second option is possible only if explicitly enabled during the Postgres installation. It is usually disabled to alleviate security and data integrity concerns.
Note: Postgres will add /base/ to the specified path to create the storage area.
The backend requires that any argument to WITH LOCATION which is in all uppercase and which has no path delimiters is an environment variable.
To create a database in an alternate location, using an environment variable:
% setenv PGDATA2 /opt/postgres/data % initlocation PGDATA2 % createdb -D PGDATA2