Server IP : 103.119.228.120 / Your IP : 3.15.203.246 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-9.2.24/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >initdb</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 9.2.24 Documentation" HREF="index.html"><LINK REL="UP" TITLE="PostgreSQL Server Applications" HREF="reference-server.html"><LINK REL="PREVIOUS" TITLE="PostgreSQL Server Applications" HREF="reference-server.html"><LINK REL="NEXT" TITLE="pg_controldata" HREF="app-pgcontroldata.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2017-11-06T22:43:11"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" ><A HREF="index.html" >PostgreSQL 9.2.24 Documentation</A ></TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A TITLE="PostgreSQL Server Applications" HREF="reference-server.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="reference-server.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="20%" ALIGN="right" VALIGN="top" ><A TITLE="pg_controldata" HREF="app-pgcontroldata.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="APP-INITDB" ></A >initdb</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN86623" ></A ><H2 >Name</H2 >initdb -- create a new <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > database cluster</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN86629" ></A ><H2 >Synopsis</H2 ><P ><TT CLASS="COMMAND" >initdb</TT > [<TT CLASS="REPLACEABLE" ><I >option</I ></TT >...] [<TT CLASS="OPTION" >--pgdata</TT > | <TT CLASS="OPTION" >-D</TT >]<TT CLASS="REPLACEABLE" ><I > directory</I ></TT > </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="R1-APP-INITDB-1" ></A ><H2 > Description </H2 ><P > <TT CLASS="COMMAND" >initdb</TT > 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 <TT CLASS="LITERAL" >template1</TT > and <TT CLASS="LITERAL" >postgres</TT > databases. When you later create a new database, everything in the <TT CLASS="LITERAL" >template1</TT > database is copied. (Therefore, anything installed in <TT CLASS="LITERAL" >template1</TT > is automatically copied into each database created later.) The <TT CLASS="LITERAL" >postgres</TT > database is a default database meant for use by users, utilities and third party applications. </P ><P > Although <TT CLASS="COMMAND" >initdb</TT > 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 <TT CLASS="COMMAND" >chown</TT > to assign ownership of that directory to the database user account, then <TT CLASS="COMMAND" >su</TT > to become the database user to run <TT CLASS="COMMAND" >initdb</TT >. </P ><P > <TT CLASS="COMMAND" >initdb</TT > 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 <TT CLASS="COMMAND" >initdb</TT > creates. Since the server cannot be run as root, you must not run <TT CLASS="COMMAND" >initdb</TT > as root either. (It will in fact refuse to do so.) </P ><P > <TT CLASS="COMMAND" >initdb</TT > initializes the database cluster's default locale and character set encoding. The character set encoding, collation order (<TT CLASS="LITERAL" >LC_COLLATE</TT >) and character set classes (<TT CLASS="LITERAL" >LC_CTYPE</TT >, e.g. upper, lower, digit) can be set separately for a database when it is created. <TT CLASS="COMMAND" >initdb</TT > determines those settings for the <TT CLASS="LITERAL" >template1</TT > database, which will serve as the default for all other databases. </P ><P > To alter the default collation order or character set classes, use the <TT CLASS="OPTION" >--lc-collate</TT > and <TT CLASS="OPTION" >--lc-ctype</TT > options. Collation orders other than <TT CLASS="LITERAL" >C</TT > or <TT CLASS="LITERAL" >POSIX</TT > also have a performance penalty. For these reasons it is important to choose the right locale when running <TT CLASS="COMMAND" >initdb</TT >. </P ><P > The remaining locale categories can be changed later when the server is started. You can also use <TT CLASS="OPTION" >--locale</TT > to set the default for all locale categories, including collation order and character set classes. All server locale values (<TT CLASS="LITERAL" >lc_*</TT >) can be displayed via <TT CLASS="COMMAND" >SHOW ALL</TT >. More details can be found in <A HREF="locale.html" >Section 22.1</A >. </P ><P > To alter the default encoding, use the <TT CLASS="OPTION" >--encoding</TT >. More details can be found in <A HREF="multibyte.html" >Section 22.3</A >. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN86681" ></A ><H2 >Options</H2 ><P > <P ></P ></P><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="OPTION" >-A <TT CLASS="REPLACEABLE" ><I >authmethod</I ></TT ></TT ><BR><TT CLASS="OPTION" >--auth=<TT CLASS="REPLACEABLE" ><I >authmethod</I ></TT ></TT ></DT ><DD ><P > This option specifies the authentication method for local users used in <TT CLASS="FILENAME" >pg_hba.conf</TT > (<TT CLASS="LITERAL" >host</TT > and <TT CLASS="LITERAL" >local</TT > lines). Do not use <TT CLASS="LITERAL" >trust</TT > unless you trust all local users on your system. <TT CLASS="LITERAL" >trust</TT > is the default for ease of installation. </P ></DD ><DT ><TT CLASS="OPTION" >--auth-host=<TT CLASS="REPLACEABLE" ><I >authmethod</I ></TT ></TT ></DT ><DD ><P > This option specifies the authentication method for local users via TCP/IP connections used in <TT CLASS="FILENAME" >pg_hba.conf</TT > (<TT CLASS="LITERAL" >host</TT > lines). </P ></DD ><DT ><TT CLASS="OPTION" >--auth-local=<TT CLASS="REPLACEABLE" ><I >authmethod</I ></TT ></TT ></DT ><DD ><P > This option specifies the authentication method for local users via Unix-domain socket connections used in <TT CLASS="FILENAME" >pg_hba.conf</TT > (<TT CLASS="LITERAL" >local</TT > lines). </P ></DD ><DT ><TT CLASS="OPTION" >-D <TT CLASS="REPLACEABLE" ><I >directory</I ></TT ></TT ><BR><TT CLASS="OPTION" >--pgdata=<TT CLASS="REPLACEABLE" ><I >directory</I ></TT ></TT ></DT ><DD ><P > This option specifies the directory where the database cluster should be stored. This is the only information required by <TT CLASS="COMMAND" >initdb</TT >, but you can avoid writing it by setting the <TT CLASS="ENVAR" >PGDATA</TT > environment variable, which can be convenient since the database server (<TT CLASS="COMMAND" >postgres</TT >) can find the database directory later by the same variable. </P ></DD ><DT ><TT CLASS="OPTION" >-E <TT CLASS="REPLACEABLE" ><I >encoding</I ></TT ></TT ><BR><TT CLASS="OPTION" >--encoding=<TT CLASS="REPLACEABLE" ><I >encoding</I ></TT ></TT ></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 <TT CLASS="LITERAL" >SQL_ASCII</TT > 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" >Section 22.3.1</A >. </P ></DD ><DT ><TT CLASS="OPTION" >--locale=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ></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 <TT CLASS="COMMAND" >initdb</TT > runs in. Locale support is described in <A HREF="locale.html" >Section 22.1</A >. </P ></DD ><DT ><TT CLASS="OPTION" >--lc-collate=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ><BR><TT CLASS="OPTION" >--lc-ctype=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ><BR><TT CLASS="OPTION" >--lc-messages=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ><BR><TT CLASS="OPTION" >--lc-monetary=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ><BR><TT CLASS="OPTION" >--lc-numeric=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ><BR><TT CLASS="OPTION" >--lc-time=<TT CLASS="REPLACEABLE" ><I >locale</I ></TT ></TT ></DT ><DD ><P > Like <TT CLASS="OPTION" >--locale</TT >, but only sets the locale in the specified category. </P ></DD ><DT ><TT CLASS="OPTION" >--no-locale</TT ></DT ><DD ><P > Equivalent to <TT CLASS="OPTION" >--locale=C</TT >. </P ></DD ><DT ><TT CLASS="OPTION" >--pwfile=<TT CLASS="REPLACEABLE" ><I >filename</I ></TT ></TT ></DT ><DD ><P > Makes <TT CLASS="COMMAND" >initdb</TT > read the database superuser's password from a file. The first line of the file is taken as the password. </P ></DD ><DT ><TT CLASS="OPTION" >-T <TT CLASS="REPLACEABLE" ><I >CFG</I ></TT ></TT ><BR><TT CLASS="OPTION" >--text-search-config=<TT CLASS="REPLACEABLE" ><I >CFG</I ></TT ></TT ></DT ><DD ><P > Sets the default text search configuration. See <A HREF="runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG" >default_text_search_config</A > for further information. </P ></DD ><DT ><TT CLASS="OPTION" >-U <TT CLASS="REPLACEABLE" ><I >username</I ></TT ></TT ><BR><TT CLASS="OPTION" >--username=<TT CLASS="REPLACEABLE" ><I >username</I ></TT ></TT ></DT ><DD ><P > Selects the user name of the database superuser. This defaults to the name of the effective user running <TT CLASS="COMMAND" >initdb</TT >. 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 ><TT CLASS="OPTION" >-W</TT ><BR><TT CLASS="OPTION" >--pwprompt</TT ></DT ><DD ><P > Makes <TT CLASS="COMMAND" >initdb</TT > 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 ><TT CLASS="OPTION" >-X <TT CLASS="REPLACEABLE" ><I >directory</I ></TT ></TT ><BR><TT CLASS="OPTION" >--xlogdir=<TT CLASS="REPLACEABLE" ><I >directory</I ></TT ></TT ></DT ><DD ><P > This option specifies the directory where the transaction log should be stored. </P ></DD ></DL ></DIV ><P> </P ><P > Other, less commonly used, options are also available: <P ></P ></P><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="OPTION" >-d</TT ><BR><TT CLASS="OPTION" >--debug</TT ></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 <TT CLASS="COMMAND" >initdb</TT > uses to create the catalog tables. This option generates a tremendous amount of extremely boring output. </P ></DD ><DT ><TT CLASS="OPTION" >-L <TT CLASS="REPLACEABLE" ><I >directory</I ></TT ></TT ></DT ><DD ><P > Specifies where <TT CLASS="COMMAND" >initdb</TT > 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 ><TT CLASS="OPTION" >-n</TT ><BR><TT CLASS="OPTION" >--noclean</TT ></DT ><DD ><P > By default, when <TT CLASS="COMMAND" >initdb</TT > 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. </P ></DD ></DL ></DIV ><P> </P ><P > Other options: <P ></P ></P><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="OPTION" >-V</TT ><BR><TT CLASS="OPTION" >--version</TT ></DT ><DD ><P > Print the <SPAN CLASS="APPLICATION" >initdb</SPAN > version and exit. </P ></DD ><DT ><TT CLASS="OPTION" >-?</TT ><BR><TT CLASS="OPTION" >--help</TT ></DT ><DD ><P > Show help about <SPAN CLASS="APPLICATION" >initdb</SPAN > command line arguments, and exit. </P ></DD ></DL ></DIV ><P> </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN86863" ></A ><H2 >Environment</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="ENVAR" >PGDATA</TT ></DT ><DD ><P > Specifies the directory where the database cluster is to be stored; can be overridden using the <TT CLASS="OPTION" >-D</TT > option. </P ></DD ><DT ><TT CLASS="ENVAR" >TZ</TT ></DT ><DD ><P > Specifies the time zone, using full time zone names, which the created database cluster should use. </P ></DD ></DL ></DIV ><P > This utility, like most other <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > utilities, also uses the environment variables supported by <SPAN CLASS="APPLICATION" >libpq</SPAN > (see <A HREF="libpq-envars.html" >Section 31.14</A >). </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN86881" ></A ><H2 >Notes</H2 ><P > <TT CLASS="COMMAND" >initdb</TT > can also be invoked via <TT CLASS="COMMAND" >pg_ctl initdb</TT >. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN86886" ></A ><H2 >See Also</H2 ><A HREF="app-pg-ctl.html" ><SPAN CLASS="APPLICATION" >pg_ctl</SPAN ></A >, <A HREF="app-postgres.html" ><SPAN CLASS="APPLICATION" >postgres</SPAN ></A ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="reference-server.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="app-pgcontroldata.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >PostgreSQL Server Applications</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="reference-server.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><SPAN CLASS="APPLICATION" >pg_controldata</SPAN ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >