createdb.sgml
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:8k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1. <refentry id="APP-CREATEDB">
  2.  <refmeta>
  3.   <refentrytitle>
  4.    <application>createdb</application>
  5.   </refentrytitle>
  6.   <refmiscinfo>Application</refmiscinfo>
  7.  </refmeta>
  8.  <refnamediv>
  9.   <refname>
  10.    <application>createdb</application>
  11.   </refname>
  12.   <refpurpose>
  13.    Create a new <productname>Postgres</productname> database
  14.   </refpurpose>
  15.  </refnamediv>
  16.  <refsynopsisdiv>
  17.   <refsynopsisdivinfo>
  18.    <date>1998-10-02</date>
  19.   </refsynopsisdivinfo>
  20.   <synopsis>
  21. createdb [ <replaceable class="parameter">dbname</replaceable> ]
  22. createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
  23.       [ -D <replaceable class="parameter">datadir</replaceable> ] [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
  24.   </synopsis>
  25.   <refsect2 id="R2-APP-CREATEDB-1">
  26.    <refsect2info>
  27.     <date>1998-10-02</date>
  28.    </refsect2info>
  29.    <title>
  30.     Inputs
  31.    </title>
  32.    <para>
  33.     <variablelist>
  34.      <varlistentry>
  35.       <term>-h <replaceable class="parameter">host</replaceable></term>
  36.       <listitem>
  37.        <para>
  38. Specifies the hostname of the machine on which the 
  39. <application>postmaster</application>
  40. is running.  Defaults to using a local Unix domain socket
  41. rather than an IP connection.
  42.        </para>
  43.       </listitem>
  44.      </varlistentry>
  45.      <varlistentry>
  46.       <term>-p <replaceable class="parameter">port</replaceable></term>
  47.       <listitem>
  48.        <para>
  49. Specifies the Internet TCP/IP port or local Unix domain socket file 
  50. extension on which the <application>postmaster</application>
  51. is listening for connections.  The port number defaults to 5432,
  52. or the value of the <envar>PGPORT</envar>
  53. environment variable (if set).
  54.        </para>
  55.       </listitem>
  56.      </varlistentry>
  57.      <varlistentry>
  58.       <term>-u</term>
  59.       <listitem>
  60.        <para>
  61. Use password authentication. 
  62. Prompts for
  63. <replaceable class="parameter">username</replaceable>
  64. and <replaceable class="parameter">password</replaceable>.
  65.        </para>
  66.       </listitem>
  67.      </varlistentry>
  68.      <varlistentry>
  69.       <term>-D <replaceable class="parameter">datadir</replaceable></term>
  70.       <listitem>
  71.        <para>
  72. Specifies the alternate database location for this database installation.
  73. This is the location of the installation system tables, not the location
  74. of this specific database, which may be different.
  75.        </para>
  76.       </listitem>
  77.      </varlistentry>
  78.      <varlistentry>
  79.       <term><replaceable class="parameter">dbname</replaceable></term>
  80.       <listitem>
  81.        <para>
  82. Specifies the name of the database to be created.  The name must be
  83. unique among all <productname>Postgres</productname> databases in this installation.
  84. <replaceable class="parameter">dbname</replaceable>
  85. defaults to the value of the
  86. <envar>USER</envar>
  87. environment variable.
  88.        </para>
  89.       </listitem>
  90.      </varlistentry>
  91.     </variablelist>
  92.    </para>
  93.   </refsect2>
  94.   <refsect2 id="R2-APP-CREATEDB-2">
  95.    <refsect2info>
  96.     <date>1998-10-02</date>
  97.    </refsect2info>
  98.    <title>
  99.     Outputs
  100.    </title>
  101.    <para>
  102.     <application>createdb</application> will create files in the
  103.     <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
  104.     data area for the new database.
  105.     <variablelist>
  106.      <varlistentry>
  107.       <term><computeroutput>
  108. Connection to database 'template1' failed.
  109. connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
  110. createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
  111.        </computeroutput></term>
  112.       <listitem>
  113.        <para>
  114. <application>createdb</application> could not attach to the 
  115. <application>postmaster</application> 
  116. process on the specified host and port.  If you see this message,
  117. ensure that the <application>postmaster</application> 
  118. is running on the proper host and that you have specified the proper
  119. port.  If your site uses an authentication system, ensure that you
  120. have obtained the required authentication credentials.
  121.        </para>
  122.       </listitem>
  123.      </varlistentry>
  124.      <varlistentry>
  125.       <term><computeroutput>
  126. Connection to database 'template1' failed.
  127. FATAL 1:  SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
  128. createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
  129.       </computeroutput></term>
  130.       <listitem>
  131.        <para>
  132. You do not have a valid entry in the relation <literal>pg_shadow</literal>
  133. and and will not be allowed to access <productname>Postgres</productname>. 
  134. Contact your <productname>Postgres</productname> administrator.
  135.        </para>
  136.       </listitem>
  137.      </varlistentry>
  138.      <varlistentry>
  139.       <term><computeroutput>
  140. ERROR:  user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
  141. createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
  142.        </computeroutput></term>
  143.       <listitem>
  144.        <para>
  145. You do not have permission to create new databases.
  146. Contact your <productname>Postgres</productname> site administrator.
  147.        </para>
  148.       </listitem>
  149.      </varlistentry>
  150.      <varlistentry>
  151.       <term><computeroutput>
  152. ERROR:  createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
  153. createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
  154.        </computeroutput></term>
  155.       <listitem>
  156.        <para>
  157. The database already exists.
  158.        </para>
  159.       </listitem>
  160.      </varlistentry>
  161.      <varlistentry>
  162.       <term><computeroutput>
  163. createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
  164.        </computeroutput></term>
  165.       <listitem>
  166.        <para>
  167. An internal error occurred in <application>psql</application>
  168. or in the backend server.  Ensure that your site administrator has
  169. properly installed <productname>Postgres</productname>and initialized the site with 
  170. <application>initdb</application>.
  171.        </para>
  172.       </listitem>
  173.      </varlistentry>
  174.     </variablelist>
  175.    </para>
  176.    <note>
  177.     <para>
  178.      <application>createdb</application> internally runs
  179.      <command>CREATE DATABASE</command> from <application>psql</application>
  180.      while connected to the <literal>template1</literal> database.
  181.     </para>
  182.    </note>
  183.   </refsect2>
  184.  </refsynopsisdiv>
  185.  <refsect1 id="R1-APP-CREATEDB-1">
  186.   <refsect1info>
  187.    <date>1998-10-02</date>
  188.   </refsect1info>
  189.   <title>
  190.    Description
  191.   </title>
  192.   <para>
  193.    <application>createdb</application> creates a new 
  194.    <productname>Postgres</productname> database.
  195.    The person who executes this command becomes
  196.    the database administrator, or <acronym>DBA</acronym>,
  197.    for this database and is the only
  198.    person, other than the <productname>Postgres</productname> super-user,
  199.    who can destroy it.
  200.   </para>
  201.   <para>
  202.    <application>createdb</application> is a shell script that invokes
  203.    <application>psql</application>.
  204.    Hence, a <application>postmaster</application>
  205.    process must be running on the database server host before
  206.    <application>createdb</application>
  207.    is executed. The 
  208.    <envar>PGOPTION</envar>
  209.    and
  210.    <envar>PGREALM</envar>
  211.    environment variables will be passed on to
  212.    <application>psql</application>
  213.    and processed as described in <xref endterm="psql-ref"
  214.     linkend="app-psql">.
  215.   </para>
  216.  </refsect1>
  217.  <refsect1 id="R1-APP-CREATEDB-2">
  218.   <refsect1info>
  219.    <date>1998-10-02</date>
  220.   </refsect1info>
  221.   <title>
  222.    Usage
  223.   </title>
  224.   <para>
  225.    To create the database <literal>demo</literal>
  226.    using the postmaster on the local host, port 5432:
  227.    <programlisting>
  228. $ createdb demo
  229.    </programlisting>
  230.   </para>
  231.   <para>
  232.    To create the database <literal>demo</literal>
  233.    using the postmaster on host eden, port 5000:
  234.    <programlisting>
  235. $ createdb -p 5000 -h eden demo
  236.    </programlisting>
  237.   </para>
  238.  </refsect1>
  239. </refentry>
  240. <!-- Keep this comment at the end of the file
  241. Local variables:
  242. mode: sgml
  243. sgml-omittag:nil
  244. sgml-shorttag:t
  245. sgml-minimize-attributes:nil
  246. sgml-always-quote-attributes:t
  247. sgml-indent-step:1
  248. sgml-indent-data:t
  249. sgml-parent-document:nil
  250. sgml-default-dtd-file:"../reference.ced"
  251. sgml-exposed-tags:nil
  252. sgml-local-catalogs:"/usr/lib/sgml/catalog"
  253. sgml-local-ecat-files:nil
  254. End:
  255. -->