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 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>initdb</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet version 1.19"><LINK
REL="HOME"
TITLE="PostgreSQL User's Guide"
HREF="user.html"><LINK
REL="UP"
TITLE="Utility Applications"
HREF="utilities.html"><LINK
REL="PREVIOUS"
TITLE="destroyuser"
HREF="app-destroyuser.html"><LINK
REL="NEXT"
TITLE="initlocation"
HREF="app-initlocation.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PostgreSQL User's Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="app-destroyuser.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="app-initlocation.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><SPAN
CLASS="APPLICATION"
>initdb</SPAN
></H1
><DIV
CLASS="REFNAMEDIV"
><H2
>Name</H2
><SPAN
CLASS="APPLICATION"
>initdb</SPAN
> — Create a new <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> database installation</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><PRE
CLASS="SYNOPSIS"
>initdb [ --pgdata=<TT
CLASS="REPLACEABLE"
><I
>dbdir</I
></TT
> | -r <TT
CLASS="REPLACEABLE"
><I
>dbdir</I
></TT
> ]
[ --pglib=<TT
CLASS="REPLACEABLE"
><I
>libdir</I
></TT
> | -l <TT
CLASS="REPLACEABLE"
><I
>libdir</I
></TT
> ]
[ --template=<TT
CLASS="REPLACEABLE"
><I
>template</I
></TT
> | -t <TT
CLASS="REPLACEABLE"
><I
>template</I
></TT
> ]
[ --username=<TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> | -u <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> ]
[ --noclean | -n ] [ --debug | -d ]</PRE
><DIV
CLASS="REFSECT2"
><H3
>Inputs</H3
><P
><P
></P
></P><DL
><DT
>--pglib=<TT
CLASS="REPLACEABLE"
><I
>libdir</I
></TT
>, -l <TT
CLASS="REPLACEABLE"
><I
>libdir</I
></TT
>, <TT
CLASS="ENVAR"
>PGLIB</TT
></DT
><DD
><P
>Where are the files that make up <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>?
Apart from files that
have to go in particular directories because of their function, the
files that make up the <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> software
were installed in a directory
called the <TT
CLASS="REPLACEABLE"
><I
>libdir</I
></TT
> directory.
An example of a file that will be found
there that <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
needs is <TT
CLASS="FILENAME"
>global1.bki.source</TT
>,
which contains all the information that goes
into the shared catalog tables. </P
></DD
><DT
>--pgdata=<TT
CLASS="REPLACEABLE"
><I
>dbdir</I
></TT
>, -r <TT
CLASS="REPLACEABLE"
><I
>dbdir</I
></TT
>, <TT
CLASS="ENVAR"
>PGDATA</TT
></DT
><DD
><P
>Where in your Unix filesystem do you want the database data to go?
The top level directory is called the <TT
CLASS="ENVAR"
>PGDATA</TT
> directory. </P
></DD
><DT
>--username=<TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
>, -u <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
>, <TT
CLASS="ENVAR"
>PGUSER</TT
></DT
><DD
><P
>Who will be the <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> superuser
for this database system? The
<SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> superuser is a Unix user
who owns all files that store the database
system and also owns the postmaster and backend processes that access them.
Or just let it default to you (the Unix user who runs
<SPAN
CLASS="APPLICATION"
>initdb</SPAN
>).
<BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Only the Unix superuser (<TT
CLASS="LITERAL"
>root</TT
>)
can create a database system with an owner
different from the <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> superuser.</P
></BLOCKQUOTE
> </P
></DD
></DL
><P> </P
><P
>Other, less commonly used, parameters are also available:
<P
></P
></P><DL
><DT
>--template=<TT
CLASS="REPLACEABLE"
><I
>template</I
></TT
>, -t <TT
CLASS="REPLACEABLE"
><I
>template</I
></TT
></DT
><DD
><P
>Replace the <TT
CLASS="LITERAL"
>template1</TT
>
database in an existing database system, and don't touch anything else.
This is useful when you need to upgrade your <TT
CLASS="LITERAL"
>template1</TT
>
database using <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
from a newer release of <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>,
or when your <TT
CLASS="LITERAL"
>template1</TT
>
database has become corrupted by some system problem. Normally the
contents of <TT
CLASS="LITERAL"
>template1</TT
>
remain constant throughout the life of the database system. You can't
destroy anything by running <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
with the
<SPAN
CLASS="OPTION"
>--template</SPAN
>
option. </P
></DD
><DT
>--noclean, -n</DT
><DD
><P
>By default, when <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
determines that error prevent it from completely creating the database
system, it removes any files it may have created before determining
that it can't finish the job. That includes any core files left by
the programs it invokes. This option inhibits any tidying-up and is
thus useful for debugging. </P
></DD
><DT
>--debug, -d</DT
><DD
><P
>Print debugging output from the bootstrap backend.
The bootstrap backend is the program <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
uses to create the catalog tables. This option generates a tremendous
amount of output. It also turns off the final vacuuming step. </P
></DD
></DL
><P> </P
><P
>Files are also input to <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>:
<P
></P
></P><DL
><DT
><SPAN
CLASS="APPLICATION"
>postconfig</SPAN
></DT
><DD
><P
>If appearing somewhere in the Unix command search path
(defined by the PATH environment variable).
This is a program that specifies defaults for some of the
command options. See below. </P
></DD
><DT
><TT
CLASS="FILENAME"
><TT
CLASS="ENVAR"
>PGLIB</TT
>/global1.bki.source</TT
></DT
><DD
><P
>Contents for the shared catalog tables in the new database system. This
file is part of the <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> software. </P
></DD
><DT
><TT
CLASS="FILENAME"
><TT
CLASS="ENVAR"
>PGLIB</TT
>/local1_template1.bki.source</TT
></DT
><DD
><P
>Contents for the template1 tables in the new database system. This
file is part of the <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> software. </P
></DD
></DL
><P> </P
></DIV
><DIV
CLASS="REFSECT2"
><H3
>Outputs</H3
><P
><SPAN
CLASS="APPLICATION"
>initdb</SPAN
> will create files in the <TT
CLASS="ENVAR"
>PGDATA</TT
>
data area which are the system tables and framework for a complete
installation. </P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><H2
>Description</H2
><P
><SPAN
CLASS="APPLICATION"
>initdb</SPAN
> creates a new
<SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> database system.
A database system is a
collection of databases that are all administered by the same Unix user
and managed by a single postmaster. </P
><P
>Creating a database system consists of creating the directories in which
the database data will live, generating the shared catalog tables
(tables that don't belong to any particular database), and
creating the <TT
CLASS="LITERAL"
>template1</TT
>
database. What is the <TT
CLASS="LITERAL"
>template1</TT
>
database? When you create a database, <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
does it by copying
everything from the <TT
CLASS="LITERAL"
>template1</TT
>
database. It contains catalog tables filled in for things like the
builtin types. </P
><P
>After <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
creates the database, it completes the initialization by running
<SPAN
CLASS="APPLICATION"
>vacuum</SPAN
>, which resets some optimization parameters. </P
><P
>There are three ways to give parameters to <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>.
First, you can use <SPAN
CLASS="APPLICATION"
>initdb</SPAN
> command options.
Second, you can set environment
variables before invoking <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>.
Third, you can have a program called <SPAN
CLASS="APPLICATION"
>postconfig</SPAN
>
in your Unix command search path.
<SPAN
CLASS="APPLICATION"
>initdb</SPAN
> invokes that program and that program then writes
<SPAN
CLASS="APPLICATION"
>initdb</SPAN
> parameters to its standard output stream.
This third option is not a common thing to do, however. </P
><P
>Command options always override parameters specified any other way.
The values returned by <SPAN
CLASS="APPLICATION"
>postconfig</SPAN
>
override any environment variables, but your
<SPAN
CLASS="APPLICATION"
>postconfig</SPAN
>
program may base its output on the environment variables if you want
their values to be used. </P
><P
>The value that <SPAN
CLASS="APPLICATION"
>postconfig</SPAN
>
outputs must have the format
<PRE
CLASS="PROGRAMLISTING"
> <TT
CLASS="REPLACEABLE"
><I
>var1</I
></TT
>=<TT
CLASS="REPLACEABLE"
><I
>value1</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>var2</I
></TT
>=<TT
CLASS="REPLACEABLE"
><I
>value2</I
></TT
> ...</PRE
>
It can output nothing if it doesn't want to supply any parameters.
The <TT
CLASS="REPLACEABLE"
><I
>var</I
></TT
> values are equal to
the corresponding environment variable
names. For example,
<PRE
CLASS="PROGRAMLISTING"
>PGDATA=/tmp/postgres_test</PRE
>
has the
same effect as invoking <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
with an environment variable called <TT
CLASS="ENVAR"
>PGDATA</TT
> whose value is
<TT
CLASS="FILENAME"
>/tmp/postgres_test</TT
>. </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-destroyuser.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="user.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-initlocation.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>destroyuser</SPAN
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="utilities.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>initlocation</SPAN
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|