Imported upstream version 1.5
[manpages-zh.git] / raw / man1 / initdb.1
blob90c140e4e127a249967fa78695addc8faea5afc4
1 .\\" auto-generated by docbook2man-spec $Revision: 1.1 $
2 .TH "INITDB" "1" "2003-11-02" "Application" "PostgreSQL Server Applications"
3 .SH NAME
4 initdb \- create a new PostgreSQL database cluster
6 .SH SYNOPSIS
7 .sp
8 \fBinitdb\fR\fR [ \fR\fB\fIoption\fB\fR...\fB \fR\fR]\fR \fR\fR \fB--pgdata \fR\fR | \fR\fB-D \fR\fIdirectory\fR\fR\fR
9 .SH "DESCRIPTION"
10 .PP
11 \fBinitdb\fR creates a new
12 PostgreSQL database cluster. A database
13 cluster is a collection of databases that are managed by a single
14 server instance.
15 .PP
16 Creating a database cluster consists of creating the directories in which
17 the database data will live, generating the shared catalog tables 
18 (tables that belong to the whole cluster rather than to any particular
19 database), and creating the template1
20 database. When you later create a new database, everything in the
21 template1 database is copied.
22 It contains catalog tables filled in for things like the
23 built-in types.
24 .PP
25 \fBinitdb\fR initializes the database cluster's
26 default locale and character set encoding. Some locale categories
27 are fixed for the lifetime of the cluster, so it is important to
28 make the right choice when running \fBinitdb\fR.
29 Other locale categories can be changed later when the server is
30 started. \fBinitdb\fR will write those locale
31 settings into the \fIpostgresql.conf\fR
32 configuration file so they are the default, but they can be changed
33 by editing that file. To set the locale that
34 \fBinitdb\fR uses, see the description of the
35 \fB--locale\fR option. The character set encoding can
36 be set separately for each database as it is created.
37 \fBinitdb\fR determines the encoding for the
38 template1 database, which will serve as the
39 default for all other databases. To alter the default encoding use
40 the \fB--encoding\fR option.
41 .PP
42 \fBinitdb\fR must be run as the user that will own the
43 server process, because the server needs to have access to the
44 files and directories that \fBinitdb\fR creates.
45 Since the server may not be run as root, you must not run
46 \fBinitdb\fR as root either. (It will in fact refuse
47 to do so.)
48 .PP
49 Although \fBinitdb\fR will attempt to create the
50 specified data directory, often it won't have permission to do so,
51 since the parent of the desired data directory is often a root-owned
52 directory. To set up an arrangement like this, create an empty data
53 directory as root, then use \fBchown\fR to hand over
54 ownership of that directory to the database user account, then
55 \fBsu\fR to become the database user, and
56 finally run \fBinitdb\fR as the database user.
57 .SH "OPTIONS"
58 .PP
59 .TP
60 \fB-D \fIdirectory\fB\fR
61 .TP
62 \fB--pgdata=\fIdirectory\fB\fR
63 This option specifies the directory where the database cluster
64 should be stored. This is the only information required by
65 \fBinitdb\fR, but you can avoid writing it by
66 setting the \fBPGDATA\fR environment variable, which
67 can be convenient since the database server
68 (\fBpostmaster\fR) can find the database
69 directory later by the same variable.
70 .TP
71 \fB-E \fIencoding\fB\fR
72 .TP
73 \fB--encoding=\fIencoding\fB\fR
74 Selects the encoding of the template database. This will also
75 be the default encoding of any database you create later, unless you
76 override it there. The default is SQL_ASCII.
77 .TP
78 \fB--locale=\fIlocale\fB\fR
79 Sets the default locale for the database cluster. If this
80 option is not specified, the locale is inherited from the
81 environment that \fBinitdb\fR runs in.
82 .TP
83 \fB--lc-collate=\fIlocale\fB\fR
84 .TP
85 \fB--lc-ctype=\fIlocale\fB\fR
86 .TP
87 \fB--lc-messages=\fIlocale\fB\fR
88 .TP
89 \fB--lc-monetary=\fIlocale\fB\fR
90 .TP
91 \fB--lc-numeric=\fIlocale\fB\fR
92 .TP
93 \fB--lc-time=\fIlocale\fB\fR
94 Like \fB--locale\fR, but only sets the locale in
95 the specified category.
96 .TP
97 \fB-U \fIusername\fB\fR
98 .TP
99 \fB--username=\fIusername\fB\fR
100 Selects the user name of the database superuser. This defaults
101 to the name of the effective user running
102 \fBinitdb\fR. It is really not important what the
103 superuser's name is, but one might choose to keep the
104 customary name \fBpostgres\fR, even if the operating
105 system user's name is different.
107 \fB-W\fR
109 \fB--pwprompt\fR
110 Makes \fBinitdb\fR prompt for a password
111 to give the database superuser. If you don't plan on using password
112 authentication, this is not important. Otherwise you won't be
113 able to use password authentication until you have a password
114 set up.
117 Other, less commonly used, parameters are also available:
119 \fB-d\fR
121 \fB--debug\fR
122 Print debugging output from the bootstrap backend and a few other
123 messages of lesser interest for the general public.
124 The bootstrap backend is the program \fBinitdb\fR
125 uses to create the catalog tables. This option generates a tremendous
126 amount of extremely boring output.
128 \fB-L \fIdirectory\fB\fR
129 Specifies where \fBinitdb\fR should find
130 its input files to initialize the database cluster. This is
131 normally not necessary. You will be told if you need to
132 specify their location explicitly.
134 \fB-n\fR
136 \fB--noclean\fR
137 By default, when \fBinitdb\fR
138 determines that an error prevented it from completely creating the database
139 cluster, it removes any files it may have created before discovering
140 that it can't finish the job. This option inhibits tidying-up and is
141 thus useful for debugging.
143 .SH "ENVIRONMENT"
145 \fBPGDATA\fR
146 Specifies the directory where the database cluster is to be
147 stored; may be overridden using the \fB-D\fR option.
148 .SH "SEE ALSO"
149 \fBpostgres\fR(1), \fBpostmaster\fR(1)