~ubuntu-branches/debian/sid/postgresql-9.3/sid

« back to all changes in this revision

Viewing changes to doc/src/sgml/man1/initdb.1

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 05:39:52 UTC
  • Revision ID: package-import@ubuntu.com-20130508053952-1j7uilp7mjtrvq8q
Tags: upstream-9.3~beta1
ImportĀ upstreamĀ versionĀ 9.3~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'\" t
 
2
.\"     Title: initdb
 
3
.\"    Author: The PostgreSQL Global Development Group
 
4
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
 
5
.\"      Date: 2013-05-06
 
6
.\"    Manual: PostgreSQL 9.3beta1 Documentation
 
7
.\"    Source: PostgreSQL 9.3beta1
 
8
.\"  Language: English
 
9
.\"
 
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
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
18
.ie \n(.g .ds Aq \(aq
 
19
.el       .ds Aq '
 
20
.\" -----------------------------------------------------------------
 
21
.\" * set default formatting
 
22
.\" -----------------------------------------------------------------
 
23
.\" disable hyphenation
 
24
.nh
 
25
.\" disable justification (adjust text to left margin only)
 
26
.ad l
 
27
.\" -----------------------------------------------------------------
 
28
.\" * MAIN CONTENT STARTS HERE *
 
29
.\" -----------------------------------------------------------------
 
30
.SH "NAME"
 
31
initdb \- create a new PostgreSQL database cluster
 
32
.\" initdb
 
33
.SH "SYNOPSIS"
 
34
.HP \w'\fBinitdb\fR\ 'u
 
35
\fBinitdb\fR [\fIoption\fR...] [\fB\-\-pgdata\fR | \fB\-D\fR]\fI directory\fR
 
36
.SH "DESCRIPTION"
 
37
.PP
 
38
 
 
39
\fBinitdb\fR
 
40
creates a new
 
41
PostgreSQL
 
42
database cluster\&. A database cluster is a collection of databases that are managed by a single server instance\&.
 
43
.PP
 
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
 
45
template1
 
46
and
 
47
postgres
 
48
databases\&. When you later create a new database, everything in the
 
49
template1
 
50
database is copied\&. (Therefore, anything installed in
 
51
template1
 
52
is automatically copied into each database created later\&.) The
 
53
postgres
 
54
database is a default database meant for use by users, utilities and third party applications\&.
 
55
.PP
 
56
Although
 
57
\fBinitdb\fR
 
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
 
59
\fBchown\fR
 
60
to assign ownership of that directory to the database user account, then
 
61
\fBsu\fR
 
62
to become the database user to run
 
63
\fBinitdb\fR\&.
 
64
.PP
 
65
 
 
66
\fBinitdb\fR
 
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
 
68
\fBinitdb\fR
 
69
creates\&. Since the server cannot be run as root, you must not run
 
70
\fBinitdb\fR
 
71
as root either\&. (It will in fact refuse to do so\&.)
 
72
.PP
 
73
 
 
74
\fBinitdb\fR
 
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\&.
 
76
\fBinitdb\fR
 
77
determines those settings for the
 
78
template1
 
79
database, which will serve as the default for all other databases\&.
 
80
.PP
 
81
To alter the default collation order or character set classes, use the
 
82
\fB\-\-lc\-collate\fR
 
83
and
 
84
\fB\-\-lc\-ctype\fR
 
85
options\&. Collation orders other than
 
86
C
 
87
or
 
88
POSIX
 
89
also have a performance penalty\&. For these reasons it is important to choose the right locale when running
 
90
\fBinitdb\fR\&.
 
91
.PP
 
92
The remaining locale categories can be changed later when the server is started\&. You can also use
 
93
\fB\-\-locale\fR
 
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\&.
 
97
.PP
 
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\&.
 
101
.SH "OPTIONS"
 
102
.PP
 
103
.PP
 
104
\fB\-A \fR\fB\fIauthmethod\fR\fR, \fB\-\-auth=\fR\fB\fIauthmethod\fR\fR
 
105
.RS 4
 
106
This option specifies the authentication method for local users used in
 
107
pg_hba\&.conf
 
108
(host
 
109
and
 
110
local
 
111
lines)\&. Do not use
 
112
trust
 
113
unless you trust all local users on your system\&.
 
114
trust
 
115
is the default for ease of installation\&.
 
116
.RE
 
117
.PP
 
118
\fB\-\-auth\-host=\fR\fB\fIauthmethod\fR\fR
 
119
.RS 4
 
120
This option specifies the authentication method for local users via TCP/IP connections used in
 
121
pg_hba\&.conf
 
122
(host
 
123
lines)\&.
 
124
.RE
 
125
.PP
 
126
\fB\-\-auth\-local=\fR\fB\fIauthmethod\fR\fR
 
127
.RS 4
 
128
This option specifies the authentication method for local users via Unix\-domain socket connections used in
 
129
pg_hba\&.conf
 
130
(local
 
131
lines)\&.
 
132
.RE
 
133
.PP
 
134
\fB\-D \fR\fB\fIdirectory\fR\fR, \fB\-\-pgdata=\fR\fB\fIdirectory\fR\fR
 
135
.RS 4
 
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
 
138
\fBPGDATA\fR
 
139
environment variable, which can be convenient since the database server (\fBpostgres\fR) can find the database directory later by the same variable\&.
 
140
.RE
 
141
.PP
 
142
\fB\-E \fR\fB\fIencoding\fR\fR, \fB\-\-encoding=\fR\fB\fIencoding\fR\fR
 
143
.RS 4
 
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
 
145
SQL_ASCII
 
146
if that does not work\&. The character sets supported by the
 
147
PostgreSQL
 
148
server are described in
 
149
Section 22.3.1, \(lqSupported Character Sets\(rq, in the documentation\&.
 
150
.RE
 
151
.PP
 
152
\fB\-k\fR, \fB\-\-data\-checksums\fR
 
153
.RS 4
 
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\&.
 
155
.RE
 
156
.PP
 
157
\fB\-\-locale=\fR\fB\fIlocale\fR\fR
 
158
.RS 4
 
159
Sets the default locale for the database cluster\&. If this option is not specified, the locale is inherited from the environment that
 
160
\fBinitdb\fR
 
161
runs in\&. Locale support is described in
 
162
Section 22.1, \(lqLocale Support\(rq, in the documentation\&.
 
163
.RE
 
164
.PP
 
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
 
166
.RS 4
 
167
Like
 
168
\fB\-\-locale\fR, but only sets the locale in the specified category\&.
 
169
.RE
 
170
.PP
 
171
\fB\-\-no\-locale\fR
 
172
.RS 4
 
173
Equivalent to
 
174
\fB\-\-locale=C\fR\&.
 
175
.RE
 
176
.PP
 
177
\fB\-N\fR, \fB\-\-nosync\fR
 
178
.RS 4
 
179
By default,
 
180
\fBinitdb\fR
 
181
will wait for all files to be written safely to disk\&. This option causes
 
182
\fBinitdb\fR
 
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\&.
 
184
.RE
 
185
.PP
 
186
\fB\-\-pwfile=\fR\fB\fIfilename\fR\fR
 
187
.RS 4
 
188
Makes
 
189
\fBinitdb\fR
 
190
read the database superuser\*(Aqs password from a file\&. The first line of the file is taken as the password\&.
 
191
.RE
 
192
.PP
 
193
\fB\-S\fR, \fB\-\-sync\-only\fR
 
194
.RS 4
 
195
Safely write all database files to disk and exit\&. This does not perform any of the normal
 
196
initdb
 
197
operations\&.
 
198
.RE
 
199
.PP
 
200
\fB\-T \fR\fB\fICFG\fR\fR, \fB\-\-text\-search\-config=\fR\fB\fICFG\fR\fR
 
201
.RS 4
 
202
Sets the default text search configuration\&. See
 
203
default_text_search_config
 
204
for further information\&.
 
205
.RE
 
206
.PP
 
207
\fB\-U \fR\fB\fIusername\fR\fR, \fB\-\-username=\fR\fB\fIusername\fR\fR
 
208
.RS 4
 
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\&.
 
212
.RE
 
213
.PP
 
214
\fB\-W\fR, \fB\-\-pwprompt\fR
 
215
.RS 4
 
216
Makes
 
217
\fBinitdb\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\&.
 
219
.RE
 
220
.PP
 
221
\fB\-X \fR\fB\fIdirectory\fR\fR, \fB\-\-xlogdir=\fR\fB\fIdirectory\fR\fR
 
222
.RS 4
 
223
This option specifies the directory where the transaction log should be stored\&.
 
224
.RE
 
225
.PP
 
226
Other, less commonly used, options are also available:
 
227
.PP
 
228
\fB\-d\fR, \fB\-\-debug\fR
 
229
.RS 4
 
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
 
231
\fBinitdb\fR
 
232
uses to create the catalog tables\&. This option generates a tremendous amount of extremely boring output\&.
 
233
.RE
 
234
.PP
 
235
\fB\-L \fR\fB\fIdirectory\fR\fR
 
236
.RS 4
 
237
Specifies where
 
238
\fBinitdb\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\&.
 
240
.RE
 
241
.PP
 
242
\fB\-n\fR, \fB\-\-noclean\fR
 
243
.RS 4
 
244
By default, when
 
245
\fBinitdb\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\&.
 
247
.RE
 
248
.PP
 
249
Other options:
 
250
.PP
 
251
\fB\-V\fR, \fB\-\-version\fR
 
252
.RS 4
 
253
Print the
 
254
initdb
 
255
version and exit\&.
 
256
.RE
 
257
.PP
 
258
\fB\-?\fR, \fB\-\-help\fR
 
259
.RS 4
 
260
Show help about
 
261
initdb
 
262
command line arguments, and exit\&.
 
263
.RE
 
264
.SH "ENVIRONMENT"
 
265
.PP
 
266
\fBPGDATA\fR
 
267
.RS 4
 
268
Specifies the directory where the database cluster is to be stored; can be overridden using the
 
269
\fB\-D\fR
 
270
option\&.
 
271
.RE
 
272
.PP
 
273
This utility, like most other
 
274
PostgreSQL
 
275
utilities, also uses the environment variables supported by
 
276
libpq
 
277
(see
 
278
Section 31.14, \(lqEnvironment Variables\(rq, in the documentation)\&.
 
279
.SH "NOTES"
 
280
.PP
 
281
 
 
282
\fBinitdb\fR
 
283
can also be invoked via
 
284
\fBpg_ctl initdb\fR\&.
 
285
.SH "SEE ALSO"
 
286
\fBpg_ctl\fR(1), \fBpostgres\fR(1)