1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.5 1999/07/22 15:09:12 thomas Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.6 1999/12/17 01:05:29 momjian Exp $
3
3
Postgres documentation
4
4
-->
5
5
@@ -15,24 +15,26 @@ Postgres documentation
15
15
<application>initdb</application>
16
16
</refname>
17
17
<refpurpose>
18
- Create a new <productname>Postgres </productname> database installation
18
+ Create a new <productname>PostgreSQL </productname> database installation
19
19
</refpurpose>
20
20
</refnamediv>
21
21
<refsynopsisdiv>
22
22
<refsynopsisdivinfo>
23
- <date>1999-07-20 </date>
23
+ <date>1999-12-17 </date>
24
24
</refsynopsisdivinfo>
25
25
<synopsis>
26
- initdb [ --pgdata=<replaceable class="parameter">dbdir</replaceable> | -r <replaceable class="parameter">dbdir</replaceable> ]
27
- [ --pglib=<replaceable class="parameter">libdir</replaceable> | -l <replaceable class="parameter">libdir</replaceable> ]
28
- [ --template=<replaceable class="parameter">template</replaceable> | -t <replaceable class="parameter">template</replaceable> ]
29
- [ --username=<replaceable class="parameter">name</replaceable> | -u <replaceable class="parameter">name</replaceable> ]
30
- [ --noclean | -n ] [ --debug | -d ]
26
+ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
27
+ [ --sysid|-i <replaceable class="parameter">sysid</replaceable> ]
28
+ [ --password|-W <replaceable class="parameter">password</replaceable> ]
29
+ [ --pgencoding|-e <replaceable class="parameter">encoding</replaceable> ]
30
+ [ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
31
+ [ --username|-u <replaceable class="parameter">name</replaceable> ]
32
+ [ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
31
33
</synopsis>
32
34
33
35
<refsect2 id="R2-APP-INITDB-1">
34
36
<refsect2info>
35
- <date>1998-10-02 </date>
37
+ <date>1999-11-17 </date>
36
38
</refsect2info>
37
39
<title>
38
40
Inputs
@@ -41,78 +43,108 @@ initdb [ --pgdata=<replaceable class="parameter">dbdir</replaceable> | -r <repla
41
43
42
44
<variablelist>
43
45
<varlistentry>
44
- <term>--pglib =<replaceable class="parameter">libdir </replaceable></term>
45
- <term>-l <replaceable class="parameter">libdir </replaceable></term>
46
- <term><envar>PGLIB </envar></term>
46
+ <term>--pgdata =<replaceable class="parameter">dbdir </replaceable></term>
47
+ <term>-D <replaceable class="parameter">dbdir </replaceable></term>
48
+ <term><envar>PGDATA </envar></term>
47
49
<listitem>
48
50
<para>
49
- Where are the files that make up <productname>Postgres</productname>?
50
- Apart from files that
51
- have to go in particular directories because of their function, the
52
- files that make up the <productname>Postgres</productname> software
53
- were installed in a directory
54
- called the <replaceable class="parameter">libdir</replaceable> directory.
55
- An example of a file that will be found
56
- there that <application>initdb</application>
57
- needs is <filename>global1.bki.source</filename>,
58
- which contains all the information that goes
59
- into the shared catalog tables.
51
+ This option specifies where in the file system the database should be
52
+ stored. This is the only information required by initdb, but you can avoid
53
+ it by setting the <envar>PGDATA</envar> environment variable, which
54
+ can be convenient since the database server (<filename>postmaster</filename>)
55
+ can find the database directory later by the same variable.
60
56
</para>
61
57
</listitem>
62
58
</varlistentry>
63
59
64
60
<varlistentry>
65
- <term>--pgdata=<replaceable class="parameter">dbdir</replaceable></term>
66
- <term>-r <replaceable class="parameter">dbdir</replaceable></term>
67
- <term><envar>PGDATA</envar></term>
61
+ <term>--sysid=<replaceable class="parameter">sysid</replaceable></term>
62
+ <term>-i <replaceable class="parameter">sysid</replaceable></term>
68
63
<listitem>
69
64
<para>
70
- Where in your Unix filesystem do you want the database data to go?
71
- The top level directory is called the <envar>PGDATA</envar> directory.
65
+ Selects the system id of the database superuser. This defaults to
66
+ the effective user id of the user running initdb. It is really
67
+ not important what the superuser's sysid is, but one might choose
68
+ to start the numbering at some number like 0 or 1.
72
69
</para>
73
70
</listitem>
74
71
</varlistentry>
75
-
72
+
76
73
<varlistentry>
77
- <term>--username=<replaceable class="parameter">name</replaceable></term>
78
- <term>-u <replaceable class="parameter">name</replaceable></term>
79
- <term><envar>PGUSER</envar></term>
74
+ <term>--password=<replaceable class="parameter">password</replaceable></term>
75
+ <term>-W <replaceable class="parameter">password</replaceable></term>
80
76
<listitem>
81
77
<para>
82
- Who will be the <productname>Postgres</productname> superuser
83
- for this database system? The
84
- <productname>Postgres</productname> superuser is a Unix user
85
- who owns all files that store the database
86
- system and also owns the postmaster and backend processes that access them.
87
- Or just let it default to you (the Unix user who runs
88
- <application>initdb</application>).
78
+ Sets the password of the database superuser. If you don't plan
79
+ on using password authentication, this is not important. If you
80
+ do, you can save yourself a trip by specifying it here, but you
81
+ can always change it later. The default password is empty.
89
82
</para>
90
- <note>
91
- <para>
92
- Only the Unix superuser (<literal>root</literal>)
93
- can create a database system with an owner
94
- different from the <productname>Postgres</productname> superuser.
95
- </para>
96
- </note>
97
83
</listitem>
98
84
</varlistentry>
99
- </variablelist>
85
+
86
+ <varlistentry>
87
+ <term>--pgencoding=<replaceable class="parameter">encoding</replaceable></term>
88
+ <term>-e <replaceable class="parameter">encoding</replaceable></term>
89
+ <listitem>
90
+ <para>
91
+ Selects the multibyte encoding of the template database. This will also
92
+ be the default encoding of any database you create later, unless you
93
+ override it there. To use the multibyte encoding feature, you must
94
+ specify so at build time, at which time you also select the default
95
+ for this option.
96
+ </para>
97
+ </listitem>
98
+ </varlistentry>
99
+
100
+ </variablelist>
100
101
</para>
101
102
102
103
<para>
103
104
Other, less commonly used, parameters are also available:
104
105
105
106
<variablelist>
106
107
<varlistentry>
107
- <term>--template=<replaceable class="parameter">template</replaceable></term>
108
- <term>-t <replaceable class="parameter">template</replaceable></term>
108
+ <term>--pglib=<replaceable class="parameter">libdir</replaceable></term>
109
+ <term>-l <replaceable class="parameter">libdir</replaceable></term>
110
+ <listitem>
111
+ <para>
112
+ initdb needs a few input files to initialize the database. This option
113
+ tells where to find them. You normally don't have to worry about this
114
+ since initdb knows about the most common installation layouts and will
115
+ find the files itself. You will be told if you need to specify their
116
+ location explicitly. If that happens, one of the files is called
117
+ <filename>global1.bki.source</filename> and is traditionally installed
118
+ along with the others in the library directory (e.g.,
119
+ <filename>/usr/local/pgsql/lib</filename>).
120
+ </para>
121
+ </listitem>
122
+ </varlistentry>
123
+
124
+ <varlistentry>
125
+ <term>--username=<replaceable class="parameter">name</replaceable></term>
126
+ <term>-u <replaceable class="parameter">name</replaceable></term>
127
+ <listitem>
128
+ <para>
129
+ The database system will be initialized with the username that is
130
+ running initdb. That is a requirement. If for some unimaginable
131
+ reason initdb cannot find out what the current user's name is,
132
+ you have to use this option. Normally, this will not be necessary
133
+ and initdb will tell you when it is.
134
+ </para>
135
+ </listitem>
136
+ </varlistentry>
137
+
138
+ <varlistentry>
139
+ <term>--template</term>
140
+ <term>-t</term>
109
141
<listitem>
110
142
<para>
111
143
Replace the <literal>template1</literal>
112
144
database in an existing database system, and don't touch anything else.
113
145
This is useful when you need to upgrade your <literal>template1</literal>
114
146
database using <application>initdb</application>
115
- from a newer release of <productname>Postgres </productname>,
147
+ from a newer release of <productname>PostgreSQL </productname>,
116
148
or when your <literal>template1</literal>
117
149
database has become corrupted by some system problem. Normally the
118
150
contents of <literal>template1</literal>
@@ -133,8 +165,7 @@ initdb [ --pgdata=<replaceable class="parameter">dbdir</replaceable> | -r <repla
133
165
By default, when <application>initdb</application>
134
166
determines that error prevent it from completely creating the database
135
167
system, it removes any files it may have created before determining
136
- that it can't finish the job. That includes any core files left by
137
- the programs it invokes. This option inhibits any tidying-up and is
168
+ that it can't finish the job. This option inhibits any tidying-up and is
138
169
thus useful for debugging.
139
170
</para>
140
171
</listitem>
@@ -145,67 +176,29 @@ initdb [ --pgdata=<replaceable class="parameter">dbdir</replaceable> | -r <repla
145
176
<term>-d</term>
146
177
<listitem>
147
178
<para>
148
- Print debugging output from the bootstrap backend.
179
+ Print debugging output from the bootstrap backend and a few other
180
+ messages of lesser interest for the general public.
149
181
The bootstrap backend is the program <application>initdb</application>
150
182
uses to create the catalog tables. This option generates a tremendous
151
- amount of output. It also turns off the final vacuuming step.
183
+ amount of output.
152
184
</para>
153
185
</listitem>
154
186
</varlistentry>
155
187
156
188
</variablelist>
157
189
</para>
158
190
159
- <para>
160
- Files are also input to <application>initdb</application>:
161
-
162
- <variablelist>
163
- <varlistentry>
164
- <term><application>postconfig</application></term>
165
- <listitem>
166
- <para>
167
- If appearing somewhere in the Unix command search path
168
- (defined by the PATH environment variable).
169
- This is a program that specifies defaults for some of the
170
- command options. See below.
171
- </para>
172
- </listitem>
173
- </varlistentry>
174
-
175
- <varlistentry>
176
- <term><filename><envar>PGLIB</envar>/global1.bki.source</filename></term>
177
- <listitem>
178
- <para>
179
- Contents for the shared catalog tables in the new database system. This
180
- file is part of the <productname>Postgres</productname> software.
181
- </para>
182
- </listitem>
183
- </varlistentry>
184
-
185
- <varlistentry>
186
- <term><filename><envar>PGLIB</envar>/local1_template1.bki.source</filename></term>
187
- <listitem>
188
- <para>
189
- Contents for the template1 tables in the new database system. This
190
- file is part of the <productname>Postgres</productname> software.
191
- </para>
192
- </listitem>
193
- </varlistentry>
194
-
195
- </variablelist>
196
- </para>
197
191
</refsect2>
198
192
199
193
<refsect2 id="R2-APP-INITDB-2">
200
194
<refsect2info>
201
- <date>1998-09-26 </date>
195
+ <date>1999-12-17 </date>
202
196
</refsect2info>
203
197
<title>
204
198
Outputs
205
199
</title>
206
200
<para>
207
- <application>initdb</application> will create files in the
208
- <envar>PGDATA</envar>
201
+ <application>initdb</application> will create files in the specified
209
202
data area which are the system tables and framework for a complete
210
203
installation.
211
204
</para>
@@ -214,14 +207,14 @@ initdb [ --pgdata=<replaceable class="parameter">dbdir</replaceable> | -r <repla
214
207
215
208
<refsect1 id="R1-APP-INITDB-1">
216
209
<refsect1info>
217
- <date>1998-09-26 </date>
210
+ <date>1999-12-17 </date>
218
211
</refsect1info>
219
212
<title>
220
213
Description
221
214
</title>
222
215
<para>
223
216
<application>initdb</application> creates a new
224
- <productname>Postgres </productname> database system.
217
+ <productname>PostgreSQL </productname> database system.
225
218
A database system is a
226
219
collection of databases that are all administered by the same Unix user
227
220
and managed by a single postmaster.
@@ -231,74 +224,37 @@ initdb [ --pgdata=<replaceable class="parameter">dbdir</replaceable> | -r <repla
231
224
the database data will live, generating the shared catalog tables
232
225
(tables that don't belong to any particular database), and
233
226
creating the <literal>template1</literal>
234
- database. What is the <literal>template1</literal>
235
- database? When you create a database, <productname>Postgres</productname>
236
- does it by copying
237
- everything from the <literal>template1</literal>
238
- database. It contains catalog tables filled in for things like the
227
+ database. When you create a new database, everything in the
228
+ <literal>template1</literal> database is copied.
229
+ It contains catalog tables filled in for things like the
239
230
builtin types.
240
231
</para>
241
- <para>
242
- After <application>initdb</application>
243
- creates the database, it completes the initialization by running
244
- <application>vacuum</application>, which resets some optimization parameters.
245
- </para>
246
- <para>
247
- There are three ways to give parameters to <application>initdb</application>.
248
232
249
- <itemizedlist>
250
- <listitem>
251
- <para>
252
- You can use <application>initdb</application> command options.
253
- </para>
254
- </listitem>
255
- <listitem>
256
- <para>
257
- You can set environment
258
- variables before invoking <application>initdb</application>.
259
- </para>
260
- </listitem>
261
-
262
- <listitem>
263
- <para>
264
- You can have a program called <application>postconfig</application>
265
- in your Unix command search path.
266
- <application>initdb</application> invokes that program and that program then writes
267
- <application>initdb</application> parameters to its standard output stream.
268
- This third option is not a common thing to do, however.
269
- </para>
270
- </listitem>
271
- </itemizedlist>
233
+ <para>
234
+ You must not execute <application>initdb</application> as root. This is
235
+ because you cannot run the database server as root either, but the
236
+ server needs to have access to the files <application>initdb</application>
237
+ creates. Furthermore, during the initialization phase, when there are no
238
+ users and no access controls installed, postgres will only connect with
239
+ the name of the current Unix user, so you must log in under the account
240
+ that will own the server process.
272
241
</para>
273
242
274
243
<para>
275
- Command options always override parameters specified any other way.
276
- The values returned by <application>postconfig</application>
277
- override any environment variables, but your
278
- <application>postconfig</application>
279
- program may base its output on the environment variables if you want
280
- their values to be used.
244
+ Although <application>initdb</application> will attempt to create the respective
245
+ data directory, chances are that it won't have the permission to do so. Thus
246
+ it is a good idea to create the data directory before running <application>initdb</application>
247
+ <emphasis>and</emphasis> to hand over the ownership of it to the database superuser.
281
248
</para>
282
249
283
250
<para>
284
- The value that <application>postconfig</application>
285
- outputs must have the format
286
- <synopsis>
287
- <replaceable>var1</replaceable>=<replaceable class="parameter">value1</replaceable> <replaceable class="parameter">var2</replaceable>=<replaceable class="parameter">value2</replaceable> ...
288
- </synopsis>
289
-
290
- It can output nothing if it doesn't want to supply any parameters.
291
- The <replaceable>var</replaceable> values are equal to
292
- the corresponding environment variable
293
- names. For example,
294
- <programlisting>
295
- PGDATA=/tmp/postgres_test
296
- </programlisting>
297
- has the
298
- same effect as invoking <application>initdb</application>
299
- with an environment variable called <envar>PGDATA</envar> whose value is
300
- <filename>/tmp/postgres_test</filename>.
251
+ Note that if you use the <option>--username</option> you must give correct
252
+ information about the name of the <emphasis>current</emphasis> user. If you don't
253
+ this will usually manifest itself in an error message about <literal>chmod</literal>
254
+ failing on a file <filename>pg_pwd</filename>, because the backend silently
255
+ refuses to create it.
301
256
</para>
257
+
302
258
</refsect1>
303
259
</refentry>
304
260
0 commit comments