1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>initdb</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="reference-server.html" title="PostgreSQL Server Applications">
<link rel="prev" href="reference-server.html" title="PostgreSQL Server Applications">
<link rel="next" href="app-ipcclean.html" title="ipcclean">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
<a name="app-initdb"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>initdb — create a new <span class="productname">PostgreSQL</span> database cluster</p>
</div>
<a name="id808649"></a><div class="refsynopsisdiv">
<h2>Synopsis</h2>
<div class="cmdsynopsis"><p><code class="command">initdb</code> [<em class="replaceable"><code>option</code></em>...] [--pgdata ] | [-D ]<em class="replaceable"><code>directory</code></em> </p></div>
</div>
<div class="refsect1" lang="en">
<a name="r1-app-initdb-1"></a><h2> Description
</h2>
<p> <code class="command">initdb</code> creates a new
<span class="productname">PostgreSQL</span> database cluster. A database
cluster is a collection of databases that are managed by a single
server instance.
</p>
<p> 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 <code class="literal">template1</code>
and <code class="literal">postgres</code> databases. When you later create a
new database, everything in the <code class="literal">template1</code> database is
copied. (Therefore, anything installed in <code class="literal">template1</code>
is automatically copied into each database created later.)
The <code class="literal">postgres</code> database is a default database meant
for use by users, utilities and third party applications.
</p>
<p> Although <code class="command">initdb</code> 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
<code class="command">chown</code> to assign ownership of that directory to the
database user account, then <code class="command">su</code> to become the
database user to run <code class="command">initdb</code>.
</p>
<p> <code class="command">initdb</code> 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 <code class="command">initdb</code> creates.
Since the server may not be run as root, you must not run
<code class="command">initdb</code> as root either. (It will in fact refuse
to do so.)
</p>
<p> <code class="command">initdb</code> initializes the database cluster's default
locale and character set encoding. The collation order
(<code class="literal">LC_COLLATE</code>) and character set classes
(<code class="literal">LC_CTYPE</code>, e.g. upper, lower, digit) are fixed for all
databases and can not be changed. Collation orders other than
<code class="literal">C</code> or <code class="literal">POSIX</code> also have a performance penalty.
For these reasons it is important to choose the right locale when
running <code class="command">initdb</code>. The remaining locale categories
can be changed later when the server is started. All server locale
values (<code class="literal">lc_*</code>) can be displayed via <code class="command">SHOW ALL</code>.
More details can be found in <a href="charset.html#locale" title="21.1.Locale Support">Section21.1, “Locale Support”</a>.
</p>
<p> The character set encoding can be set separately for a database when
it is created. <code class="command">initdb</code> determines the encoding for
the <code class="literal">template1</code> database, which will serve as the
default for all other databases. To alter the default encoding use
the <code class="option">--encoding</code> option. More details can be found in
<a href="multibyte.html" title="21.2.Character Set Support">Section21.2, “Character Set Support”</a>.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id808935"></a><h2>Options</h2>
<p> </p>
<div class="variablelist"><dl>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-A <em class="replaceable"><code>authmethod</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--auth=<em class="replaceable"><code>authmethod</code></em></code></span>
</dt>
<dd><p> This option specifies the authentication method for local users
used in <code class="filename">pg_hba.conf</code>. Do not use <code class="literal">trust</code>
unless you trust all local users on your system. <code class="literal">Trust</code>
is the default for ease of installation.
</p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-D <em class="replaceable"><code>directory</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span>
</dt>
<dd><p> This option specifies the directory where the database cluster
should be stored. This is the only information required by
<code class="command">initdb</code>, but you can avoid writing it by
setting the <code class="envar">PGDATA</code> environment variable, which
can be convenient since the database server
(<code class="command">postmaster</code>) can find the database
directory later by the same variable.
</p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-E <em class="replaceable"><code>encoding</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span>
</dt>
<dd><p> 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
<code class="literal">SQL_ASCII</code> if that does not work. The character sets supported by
the <span class="productname">PostgreSQL</span> server are described
in <a href="multibyte.html#multibyte-charset-supported" title="21.2.1.Supported Character Sets">Section21.2.1, “Supported Character Sets”</a>.
</p></dd>
<dt><span class="term"><code class="option">--locale=<em class="replaceable"><code>locale</code></em></code></span></dt>
<dd><p> Sets the default locale for the database cluster. If this
option is not specified, the locale is inherited from the
environment that <code class="command">initdb</code> runs in. Locale
support is described in <a href="charset.html#locale" title="21.1.Locale Support">Section21.1, “Locale Support”</a>.
</p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">--lc-collate=<em class="replaceable"><code>locale</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">--lc-ctype=<em class="replaceable"><code>locale</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">--lc-messages=<em class="replaceable"><code>locale</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">--lc-monetary=<em class="replaceable"><code>locale</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">--lc-numeric=<em class="replaceable"><code>locale</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--lc-time=<em class="replaceable"><code>locale</code></em></code></span>
</dt>
<dd><p> Like <code class="option">--locale</code>, but only sets the locale in
the specified category.
</p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-U <em class="replaceable"><code>username</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span>
</dt>
<dd><p> Selects the user name of the database superuser. This defaults
to the name of the effective user running
<code class="command">initdb</code>. It is really not important what the
superuser's name is, but one might choose to keep the
customary name <span class="systemitem">postgres</span>, even if the operating
system user's name is different.
</p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-W</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--pwprompt</code></span>
</dt>
<dd><p> Makes <code class="command">initdb</code> prompt for a password
to give the database superuser. If you don't plan on using password
authentication, this is not important. Otherwise you won't be
able to use password authentication until you have a password
set up.
</p></dd>
<dt><span class="term"><code class="option">--pwfile=<em class="replaceable"><code>filename</code></em></code></span></dt>
<dd><p> Makes <code class="command">initdb</code> read the database superuser's password
from a file. The first line of the file is taken as the password.
</p></dd>
</dl></div>
<p>
</p>
<p> Other, less commonly used, parameters are also available:
</p>
<div class="variablelist"><dl>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-d</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--debug</code></span>
</dt>
<dd><p> 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 <code class="command">initdb</code>
uses to create the catalog tables. This option generates a tremendous
amount of extremely boring output.
</p></dd>
<dt><span class="term"><code class="option">-L <em class="replaceable"><code>directory</code></em></code></span></dt>
<dd><p> Specifies where <code class="command">initdb</code> 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.
</p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-n</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--noclean</code></span>
</dt>
<dd><p> By default, when <code class="command">initdb</code>
determines that an error prevented it from completely creating the database
cluster, it removes any files it may have created before discovering
that it can't finish the job. This option inhibits tidying-up and is
thus useful for debugging.
</p></dd>
</dl></div>
<p>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id809327"></a><h2>Environment</h2>
<div class="variablelist"><dl>
<dt><span class="term"><code class="envar">PGDATA</code></span></dt>
<dd><p> Specifies the directory where the database cluster is to be
stored; may be overridden using the <code class="option">-D</code> option.
</p></dd>
</dl></div>
</div>
<div class="refsect1" lang="en">
<a name="id809347"></a><h2>See Also</h2>
<span class="simplelist"><a href="app-postgres.html" title="postgres"><span class="refentrytitle"><a name="app-postgres-title"></a><span class="application">postgres</span></span></a>, <a href="app-postmaster.html" title="postmaster"><span class="refentrytitle"><a name="app-postmaster-title"></a><span class="application">postmaster</span></span></a></span>
</div>
</div></body>
</html>
|