⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 start.sgml

📁 PostgreSQL 8.1.4的源码 适用于Linux下的开源数据库系统
💻 SGML
📖 第 1 页 / 共 2 页
字号:
<!--$PostgreSQL: pgsql/doc/src/sgml/start.sgml,v 1.39 2005/06/21 04:02:30 tgl Exp $--> <chapter id="tutorial-start">  <title>Getting Started</title>  <sect1 id="tutorial-install">   <title>Installation</title>   <para>    Before you can use <productname>PostgreSQL</productname> you need    to install it, of course.  It is possible that    <productname>PostgreSQL</productname> is already installed at your    site, either because it was included in your operating system    distribution or because the system administrator already installed    it.  If that is the case, you should obtain information from the    operating system documentation or your system administrator about    how to access <productname>PostgreSQL</productname>.   </para>   <para>    If you are not sure whether <productname>PostgreSQL</productname>    is already available or whether you can use it for your    experimentation then you can install it yourself.  Doing so is not    hard and it can be a good exercise.    <productname>PostgreSQL</productname> can be installed by any    unprivileged user; no superuser (<systemitem>root</systemitem>)    access is required.   </para>   <para>    If you are installing <productname>PostgreSQL</productname>    yourself, then refer to <xref linkend="installation">    for instructions on installation, and return to    this guide when the installation is complete.  Be sure to follow    closely the section about setting up the appropriate environment    variables.   </para>   <para>    If your site administrator has not set things up in the default    way, you may have some more work to do.  For example, if the    database server machine is a remote machine, you will need to set    the <envar>PGHOST</envar> environment variable to the name of the    database server machine.  The environment variable    <envar>PGPORT</envar> may also have to be set.  The bottom line is    this: if you try to start an application program and it complains    that it cannot connect to the database, you should consult your    site administrator or, if that is you, the documentation to make    sure that your environment is properly set up.  If you did not    understand the preceding paragraph then read the next section.   </para>  </sect1>  <sect1 id="tutorial-arch">   <title>Architectural Fundamentals</title>   <para>    Before we proceed, you should understand the basic    <productname>PostgreSQL</productname> system architecture.    Understanding how the parts of    <productname>PostgreSQL</productname> interact will make this    chapter somewhat clearer.   </para>   <para>    In database jargon, <productname>PostgreSQL</productname> uses a    client/server model.  A <productname>PostgreSQL</productname>    session consists of the following cooperating processes    (programs):    <itemizedlist>     <listitem>      <para>       A server process, which manages the database files, accepts       connections to the database from client applications, and       performs actions on the database on behalf of the clients.  The       database server program is called       <filename>postmaster</filename>.       <indexterm><primary>postmaster</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.  For that purpose 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>postmaster</filename> process.  Thus, the    <filename>postmaster</filename> 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.  He should have told you what the name of your    database is.  In that case you can omit this step and skip ahead    to the next section.   </para>   <para>    To create a new database, in this example named    <literal>mydb</literal>, you use the following command:<screen><prompt>$</prompt> <userinput>createdb mydb</userinput></screen>    This should produce as response:<screen>CREATE DATABASE</screen>    If so, 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</> was not installed properly.  Either it was not    installed at all or the search path was not set correctly.  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 back in the installation instructions to    correct the situation.   </para>   <para>    Another response could be this:<screen>createdb: could not connect to database postgres: could not connect to server:No such file or directory        Is the server running locally and accepting        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?</screen>    This means that the server was not started, or it was not started    where <command>createdb</command> expected it.  Again, check the    installation instructions or consult the administrator.   </para>   <para>    Another response could be this:<screen>createdb: could not connect to database postgres: FATAL:  user "joe" does notexist</screen>    where your own login name is mentioned.  This will happen if the    administrator has not created a <productname>PostgreSQL</> user account    for you.  (<productname>PostgreSQL</> user accounts are distinct from    operating system user accounts.)  If you are the administrator, see    <xref linkend="user-manag"> for help creating accounts.  You will need to    become the operating system user under which <productname>PostgreSQL</>    was installed (usually <literal>postgres</>) to create the first user    account.  It could also be that you were assigned a    <productname>PostgreSQL</> user name that is different from your    operating system user name; in that case you need to use the <option>-U</>    switch or set the <envar>PGUSER</> environment variable to specify your    <productname>PostgreSQL</> user name.   </para>   <para>    If you have a user account but it does not have the privileges required to    create a database, you will see the following:<screen>createdb: database creation failed: ERROR:  permission denied to create database</screen>    Not every user has authorization to create new databases.  If    <productname>PostgreSQL</productname> refuses to create databases

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -