Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/start.sgml`
8a90dbb3a29a64651d25b40ee5dfe491233ce95159f552d90000000100000fac
     performs database actions on behalf of the clients.  The
       database server program is called
       <filename>postgres</filename>.
       <indexterm><primary>postgres</primary></indexterm>
      </para>
     </listitem>

     <listitem>
      <para>
       The user's client (frontend) application that wants to perform
       database operations.  Client applications can be very diverse
       in nature:  a client could be a text-oriented tool, a graphical
       application, a web server that accesses the database to
       display web pages, or a specialized database maintenance tool.
       Some client applications are supplied with the
       <productname>PostgreSQL</productname> distribution; most are
       developed by users.
      </para>
     </listitem>

    </itemizedlist>
   </para>

   <para>
    As is typical of client/server applications, the client and the
    server can be on different hosts.  In that case they communicate
    over a TCP/IP network connection.  You should keep this in mind,
    because the files that can be accessed on a client machine might
    not be accessible (or might only be accessible using a different
    file name) on the database server machine.
   </para>

   <para>
    The <productname>PostgreSQL</productname> server can handle
    multiple concurrent connections from clients.  To achieve this it
    starts (<quote>forks</quote>) a new process for each connection.
    From that point on, the client and the new server process
    communicate without intervention by the original
    <filename>postgres</filename> process.  Thus, the
    supervisor server process is always running, waiting for
    client connections, whereas client and associated server processes
    come and go.  (All of this is of course invisible to the user.  We
    only mention it here for completeness.)
   </para>
  </sect1>


  <sect1 id="tutorial-createdb">
   <title>Creating a Database</title>

   <indexterm zone="tutorial-createdb">
    <primary>database</primary>
    <secondary>creating</secondary>
   </indexterm>

   <indexterm zone="tutorial-createdb">
    <primary>createdb</primary>
   </indexterm>

   <para>
    The first test to see whether you can access the database server
    is to try to create a database.  A running
    <productname>PostgreSQL</productname> server can manage many
    databases.  Typically, a separate database is used for each
    project or for each user.
   </para>

   <para>
    Possibly, your site administrator has already created a database
    for your use.  In that case you can omit this step and skip ahead
    to the next section.
   </para>

   <para>
    To create a new database from the command line, in this example named
    <literal>mydb</literal>, you use the following command:
<screen>
<prompt>$</prompt> <userinput>createdb mydb</userinput>
</screen>
    If this produces no response then this step was successful and you can skip over the
    remainder of this section.
   </para>

   <para>
    If you see a message similar to:
<screen>
createdb: command not found
</screen>
    then <productname>PostgreSQL</productname> was not installed properly.  Either it was not
    installed at all or your shell's search path was not set to include it.
    Try calling the command with an absolute path instead:
<screen>
<prompt>$</prompt> <userinput>/usr/local/pgsql/bin/createdb mydb</userinput>
</screen>
    The path at your site might be different.  Contact your site
    administrator or check the installation instructions to
    correct the situation.
   </para>

   <para>
    Another response could be this:
<screen>
createdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
</screen>
    This means that the server was not started, or it is not listening
    where <command>createdb</command> expects to contact it.  Again, check the
    installation instructions

Title: PostgreSQL Architecture and Database Creation
Summary
This section details the PostgreSQL client/server architecture, explaining how clients and the server communicate, potentially over a TCP/IP network. The server handles multiple client connections by creating a new process for each. The original 'postgres' process manages connections. It then explains how to create a new database using the 'createdb' command, troubleshooting common errors like 'command not found' (indicating installation issues) or connection failures (suggesting the server isn't running or accessible).