2003-10-06 17:07:10 +08:00
|
|
|
<sect2>
|
|
|
|
<title>Installation of <application>Postgre<acronym>SQL</acronym></application></title>
|
|
|
|
|
|
|
|
<para>Install <application>Postgre<acronym>SQL</acronym></application> with the following commands: </para>
|
|
|
|
|
|
|
|
<screen><userinput><command>./configure --prefix=/usr &&
|
|
|
|
make &&
|
|
|
|
make install</command></userinput></screen>
|
|
|
|
|
2004-02-09 01:08:32 +08:00
|
|
|
<note><para>If you are upgrading an existing system and are going to
|
|
|
|
install the new files over the old ones, then you should
|
|
|
|
back up your data, shut down the old server and follow the
|
|
|
|
instructions in <ulink
|
|
|
|
url="http://www.postgresql.org/docs/7.4/static/install-upgrading.html">the
|
|
|
|
official <application>Postgre<acronym>SQL</acronym></application>
|
|
|
|
documentation</ulink>.</para></note>
|
|
|
|
|
2003-10-06 17:07:10 +08:00
|
|
|
<para>Initialize a database cluster with the following commands:</para>
|
|
|
|
|
|
|
|
<screen><userinput><command>mkdir -p /var/pgsql/data &&
|
|
|
|
useradd -d /var/pgsql/data postgres &&
|
|
|
|
chown postgres /var/pgsql/data &&
|
|
|
|
su - postgres -c '/usr/bin/initdb -D /var/pgsql/data'</command></userinput></screen>
|
|
|
|
|
|
|
|
<para>Start the database server with the following command:</para>
|
|
|
|
|
|
|
|
<screen><userinput><command>su - postgres -c '/usr/bin/postmaster -D /var/pgsql/data > \
|
2004-02-09 01:08:32 +08:00
|
|
|
/var/pgsql/data/logfile 2>&1 &'</command></userinput></screen>
|
2003-10-06 17:07:10 +08:00
|
|
|
|
|
|
|
<para>Now we can create a database and verify the installation:</para>
|
|
|
|
|
2004-02-09 01:08:32 +08:00
|
|
|
<screen><userinput><command>su - postgres -c '/usr/bin/createdb test' &&
|
2003-10-06 17:07:10 +08:00
|
|
|
echo "create table t1 ( name varchar(20), state_province varchar(20) );" \
|
2004-02-09 01:08:32 +08:00
|
|
|
| (su - postgres -c '/usr/bin/psql test ') &&
|
2003-10-06 17:07:10 +08:00
|
|
|
echo "insert into t1 values ('Billy', 'NewYork');" \
|
2004-02-09 01:08:32 +08:00
|
|
|
| (su - postgres -c '/usr/bin/psql test ') &&
|
2003-10-06 17:07:10 +08:00
|
|
|
echo "insert into t1 values ('Evanidus', 'Quebec');" \
|
2004-02-09 01:08:32 +08:00
|
|
|
| (su - postgres -c '/usr/bin/psql test ') &&
|
2003-10-06 17:07:10 +08:00
|
|
|
echo "insert into t1 values ('Jesse', 'Ontario');" \
|
2004-02-09 01:08:32 +08:00
|
|
|
| (su - postgres -c '/usr/bin/psql test ') &&
|
2003-10-06 17:07:10 +08:00
|
|
|
echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')</command></userinput></screen>
|
|
|
|
|
|
|
|
</sect2>
|