Home Explore Blog CI



postgresql

13th chunk of `doc/src/sgml/ref/pg_restore.sgml`
b05a8049cd44ecceab50a088814fd626d91266f4b06fc89f0000000100000fa0
 about <application>pg_restore</application> command line
       arguments, and exit.
       </para>
       </listitem>
     </varlistentry>

    </variablelist>
   </para>

   <para>
    <application>pg_restore</application> also accepts
    the following command line arguments for connection parameters:

    <variablelist>
     <varlistentry>
      <term><option>-h <replaceable class="parameter">host</replaceable></option></term>
      <term><option>--host=<replaceable class="parameter">host</replaceable></option></term>
      <listitem>
       <para>
        Specifies the host name of the machine on which the server is
        running.  If the value begins with a slash, it is used as the
        directory for the Unix domain socket. The default is taken
        from the <envar>PGHOST</envar> environment variable, if set,
        else a Unix domain socket connection is attempted.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-p <replaceable class="parameter">port</replaceable></option></term>
      <term><option>--port=<replaceable class="parameter">port</replaceable></option></term>
      <listitem>
       <para>
        Specifies the TCP port or local Unix domain socket file
        extension on which the server is listening for connections.
        Defaults to the <envar>PGPORT</envar> environment variable, if
        set, or a compiled-in default.
        </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-U <replaceable>username</replaceable></option></term>
      <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
      <listitem>
       <para>
        User name to connect as.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-w</option></term>
      <term><option>--no-password</option></term>
      <listitem>
       <para>
        Never issue a password prompt.  If the server requires
        password authentication and a password is not available by
        other means such as a <filename>.pgpass</filename> file, the
        connection attempt will fail.  This option can be useful in
        batch jobs and scripts where no user is present to enter a
        password.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-W</option></term>
      <term><option>--password</option></term>
      <listitem>
       <para>
        Force <application>pg_restore</application> to prompt for a
        password before connecting to a database.
       </para>

       <para>
        This option is never essential, since
        <application>pg_restore</application> will automatically prompt
        for a password if the server demands password authentication.
        However, <application>pg_restore</application> will waste a
        connection attempt finding out that the server wants a password.
        In some cases it is worth typing <option>-W</option> to avoid the extra
        connection attempt.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--role=<replaceable class="parameter">rolename</replaceable></option></term>
      <listitem>
       <para>
        Specifies a role name to be used to perform the restore.
        This option causes <application>pg_restore</application> to issue a
        <command>SET ROLE</command> <replaceable class="parameter">rolename</replaceable>
        command after connecting to the database. It is useful when the
        authenticated user (specified by <option>-U</option>) lacks privileges
        needed by <application>pg_restore</application>, but can switch to a role with
        the required rights.  Some installations have a policy against
        logging in directly as a superuser, and use of this option allows
        restores to be performed without violating the policy.
       </para>
      </listitem>
     </varlistentry>


Title: pg_restore: Connection Parameters (Host, Port, User, Password, Role)
Summary
This section details command line arguments for pg_restore related to establishing the connection to the PostgreSQL server. It covers options for specifying the host, port, username, and password. It also includes options to prevent password prompts or force password prompts. The section also describes the option to specify a role to be used for the restore operation.