3
.\" Author: The PostgreSQL Global Development Group
4
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
6
.\" Manual: PostgreSQL 9.3beta1 Documentation
7
.\" Source: PostgreSQL 9.3beta1
10
.TH "INITDB" "1" "2013-05-06" "PostgreSQL 9.3beta1" "PostgreSQL 9.3beta1 Documentation"
11
.\" -----------------------------------------------------------------
12
.\" * Define some portability stuff
13
.\" -----------------------------------------------------------------
14
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
.\" http://bugs.debian.org/507673
16
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
.\" -----------------------------------------------------------------
21
.\" * set default formatting
22
.\" -----------------------------------------------------------------
23
.\" disable hyphenation
25
.\" disable justification (adjust text to left margin only)
27
.\" -----------------------------------------------------------------
28
.\" * MAIN CONTENT STARTS HERE *
29
.\" -----------------------------------------------------------------
31
initdb \- create a new PostgreSQL database cluster
34
.HP \w'\fBinitdb\fR\ 'u
35
\fBinitdb\fR [\fIoption\fR...] [\fB\-\-pgdata\fR | \fB\-D\fR]\fI directory\fR
42
database cluster\&. A database cluster is a collection of databases that are managed by a single server instance\&.
44
Creating a database cluster consists of creating the directories in which the database data will live, generating the shared catalog tables (tables that belong to the whole cluster rather than to any particular database), and creating the
48
databases\&. When you later create a new database, everything in the
50
database is copied\&. (Therefore, anything installed in
52
is automatically copied into each database created later\&.) The
54
database is a default database meant for use by users, utilities and third party applications\&.
58
will attempt to create the specified data directory, it might not have permission if the parent directory of the desired data directory is root\-owned\&. To initialize in such a setup, create an empty data directory as root, then use
60
to assign ownership of that directory to the database user account, then
62
to become the database user to run
67
must be run as the user that will own the server process, because the server needs to have access to the files and directories that
69
creates\&. Since the server cannot be run as root, you must not run
71
as root either\&. (It will in fact refuse to do so\&.)
75
initializes the database cluster\*(Aqs default locale and character set encoding\&. The character set encoding, collation order (LC_COLLATE) and character set classes (LC_CTYPE, e\&.g\&. upper, lower, digit) can be set separately for a database when it is created\&.
77
determines those settings for the
79
database, which will serve as the default for all other databases\&.
81
To alter the default collation order or character set classes, use the
85
options\&. Collation orders other than
89
also have a performance penalty\&. For these reasons it is important to choose the right locale when running
92
The remaining locale categories can be changed later when the server is started\&. You can also use
94
to set the default for all locale categories, including collation order and character set classes\&. All server locale values (lc_*) can be displayed via
95
\fBSHOW ALL\fR\&. More details can be found in
96
Section 22.1, \(lqLocale Support\(rq, in the documentation\&.
98
To alter the default encoding, use the
99
\fB\-\-encoding\fR\&. More details can be found in
100
Section 22.3, \(lqCharacter Set Support\(rq, in the documentation\&.
104
\fB\-A \fR\fB\fIauthmethod\fR\fR, \fB\-\-auth=\fR\fB\fIauthmethod\fR\fR
106
This option specifies the authentication method for local users used in
113
unless you trust all local users on your system\&.
115
is the default for ease of installation\&.
118
\fB\-\-auth\-host=\fR\fB\fIauthmethod\fR\fR
120
This option specifies the authentication method for local users via TCP/IP connections used in
126
\fB\-\-auth\-local=\fR\fB\fIauthmethod\fR\fR
128
This option specifies the authentication method for local users via Unix\-domain socket connections used in
134
\fB\-D \fR\fB\fIdirectory\fR\fR, \fB\-\-pgdata=\fR\fB\fIdirectory\fR\fR
136
This option specifies the directory where the database cluster should be stored\&. This is the only information required by
137
\fBinitdb\fR, but you can avoid writing it by setting the
139
environment variable, which can be convenient since the database server (\fBpostgres\fR) can find the database directory later by the same variable\&.
142
\fB\-E \fR\fB\fIencoding\fR\fR, \fB\-\-encoding=\fR\fB\fIencoding\fR\fR
144
Selects the encoding of the template database\&. This will also be the default encoding of any database you create later, unless you override it there\&. The default is derived from the locale, or
146
if that does not work\&. The character sets supported by the
148
server are described in
149
Section 22.3.1, \(lqSupported Character Sets\(rq, in the documentation\&.
152
\fB\-k\fR, \fB\-\-data\-checksums\fR
154
Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent\&. Enabling checksums may incur a noticeable performance penalty\&. This option can only be set during initialization, and cannot be changed later\&. If set, checksums are calculated for all objects, in all databases\&.
157
\fB\-\-locale=\fR\fB\fIlocale\fR\fR
159
Sets the default locale for the database cluster\&. If this option is not specified, the locale is inherited from the environment that
161
runs in\&. Locale support is described in
162
Section 22.1, \(lqLocale Support\(rq, in the documentation\&.
165
\fB\-\-lc\-collate=\fR\fB\fIlocale\fR\fR, \fB\-\-lc\-ctype=\fR\fB\fIlocale\fR\fR, \fB\-\-lc\-messages=\fR\fB\fIlocale\fR\fR, \fB\-\-lc\-monetary=\fR\fB\fIlocale\fR\fR, \fB\-\-lc\-numeric=\fR\fB\fIlocale\fR\fR, \fB\-\-lc\-time=\fR\fB\fIlocale\fR\fR
168
\fB\-\-locale\fR, but only sets the locale in the specified category\&.
174
\fB\-\-locale=C\fR\&.
177
\fB\-N\fR, \fB\-\-nosync\fR
181
will wait for all files to be written safely to disk\&. This option causes
183
to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt\&. Generally, this option is useful for testing, but should not be used when creating a production installation\&.
186
\fB\-\-pwfile=\fR\fB\fIfilename\fR\fR
190
read the database superuser\*(Aqs password from a file\&. The first line of the file is taken as the password\&.
193
\fB\-S\fR, \fB\-\-sync\-only\fR
195
Safely write all database files to disk and exit\&. This does not perform any of the normal
200
\fB\-T \fR\fB\fICFG\fR\fR, \fB\-\-text\-search\-config=\fR\fB\fICFG\fR\fR
202
Sets the default text search configuration\&. See
203
default_text_search_config
204
for further information\&.
207
\fB\-U \fR\fB\fIusername\fR\fR, \fB\-\-username=\fR\fB\fIusername\fR\fR
209
Selects the user name of the database superuser\&. This defaults to the name of the effective user running
210
\fBinitdb\fR\&. It is really not important what the superuser\*(Aqs name is, but one might choose to keep the customary name
211
postgres, even if the operating system user\*(Aqs name is different\&.
214
\fB\-W\fR, \fB\-\-pwprompt\fR
218
prompt for a password to give the database superuser\&. If you don\*(Aqt plan on using password authentication, this is not important\&. Otherwise you won\*(Aqt be able to use password authentication until you have a password set up\&.
221
\fB\-X \fR\fB\fIdirectory\fR\fR, \fB\-\-xlogdir=\fR\fB\fIdirectory\fR\fR
223
This option specifies the directory where the transaction log should be stored\&.
226
Other, less commonly used, options are also available:
228
\fB\-d\fR, \fB\-\-debug\fR
230
Print debugging output from the bootstrap backend and a few other messages of lesser interest for the general public\&. The bootstrap backend is the program
232
uses to create the catalog tables\&. This option generates a tremendous amount of extremely boring output\&.
235
\fB\-L \fR\fB\fIdirectory\fR\fR
239
should find its input files to initialize the database cluster\&. This is normally not necessary\&. You will be told if you need to specify their location explicitly\&.
242
\fB\-n\fR, \fB\-\-noclean\fR
246
determines that an error prevented it from completely creating the database cluster, it removes any files it might have created before discovering that it cannot finish the job\&. This option inhibits tidying\-up and is thus useful for debugging\&.
251
\fB\-V\fR, \fB\-\-version\fR
258
\fB\-?\fR, \fB\-\-help\fR
262
command line arguments, and exit\&.
268
Specifies the directory where the database cluster is to be stored; can be overridden using the
273
This utility, like most other
275
utilities, also uses the environment variables supported by
278
Section 31.14, \(lqEnvironment Variables\(rq, in the documentation)\&.
283
can also be invoked via
284
\fBpg_ctl initdb\fR\&.
286
\fBpg_ctl\fR(1), \fBpostgres\fR(1)