Diff for /wikisrc/pkgsrc/how_to_install_a_postgresql_server.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/20 20:28:27 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 Installing a PostgreSQL Server under NetBSD is pretty easy. The recommended way is to install the prebuilt postgresql binaries. The PostgreSQL Server depends on the postgreSQL Client.  Installing a PostgreSQL Server under NetBSD is pretty easy. The recommended way is to install the prebuilt postgresql binaries. The PostgreSQL Server depends on the postgreSQL Client. 
    [4]:     [4]: 
   
 **Contents**  **Contents**
   
 [[!toc levels=3]]  [[!toc levels=3]]
   
 #   Setting PKG_PATH  #   Setting PKG_PATH 
   
 Setting PKG_PATH enables us to easily download and install packages and it's dependencies.  Setting PKG_PATH enables us to easily download and install packages and it's dependencies. 
          
     # export PKG_PATH=ftp://ftp4.de.netbsd.org/pub/NetBSD/packages/3.0/i386/All      # export PKG_PATH=ftp://ftp4.de.netbsd.org/pub/NetBSD/packages/3.0/i386/All
          
   
 or if you are using csh:  or if you are using csh: 
          
     # setenv PKG_PATH ftp://ftp4.de.netbsd.org/pub/NetBSD/packages/3.0/i386/All      # setenv PKG_PATH ftp://ftp4.de.netbsd.org/pub/NetBSD/packages/3.0/i386/All
          
   
 You should keep this in your .profile, .bash_profile, if you mainly using binaries.  You should keep this in your .profile, .bash_profile, if you mainly using binaries. 
   
 #   Installing the PostgreSQL Server  #   Installing the PostgreSQL Server 
          
     # pkg_add -v postgresql80-server-8.0.4.tgz      # pkg_add -v postgresql80-server-8.0.4.tgz
          
   
 This will install the postgresql client and the server and any missing dependency (readline, perl) and will add the user **pgsql** to your user database.  This will install the postgresql client and the server and any missing dependency (readline, perl) and will add the user **pgsql** to your user database. 
   
 That's it. Almost.  That's it. Almost. 
   
 #   Configuring the Server  #   Configuring the Server 
   
 Please copy the pgsql example script to /etc/rc.d/  Please copy the pgsql example script to /etc/rc.d/ 
          
     # cp /usr/pkg/share/examples/rc.d/pgsql /etc/rc.d      # cp /usr/pkg/share/examples/rc.d/pgsql /etc/rc.d
          
   
 If you want to keep the databse cluster other place than the default location, just change the user **pgsql'**s home directory, before proceeding to the initialisation:  If you want to keep the databse cluster other place than the default location, just change the user **pgsql'**s home directory, before proceeding to the initialisation: 
          
     # usermode -d /var/db/pgsql pgsql      # usermode -d /var/db/pgsql pgsql
          
   
 This directory must be owned by pgsql:pgsql.  This directory must be owned by pgsql:pgsql. 
   
 and then  and then 
   
 #   Starting the Server  #   Starting the Server 
   
 If you want to initialise the database with a local other than "C", for example with unicode, invoke this before starting postgresql for the first time:  If you want to initialise the database with a local other than "C", for example with unicode, invoke this before starting postgresql for the first time: 
          
     # /etc/rc.d/pgsql initdb -E unicode      # /etc/rc.d/pgsql initdb -E unicode
          
   
 please start the server entering:  please start the server entering: 
          
     # /etc/rc.d/pgsql start      # /etc/rc.d/pgsql start
          
   
 This will create all necessary initial databases on the first start.  This will create all necessary initial databases on the first start. 
   
 #   Start on every boot  #   Start on every boot 
   
 To start the server on every boot add  To start the server on every boot add 
          
     pgsql=yes      pgsql=yes
          
   
 to your /etc/rc.conf  to your /etc/rc.conf 
   
 #   Creating an example Database  #   Creating an example Database 
   
 To create a database switch to the user pgsql  To create a database switch to the user pgsql 
          
     # su pgsql      # su pgsql
          
   
 and create the database  and create the database 
          
     $ createdb testdb      $ createdb testdb
     $ exit      $ exit
          
   
 #   Using the Database  #   Using the Database 
   
 Postgres provides a Tool to manage the Database called **psql**.  Postgres provides a Tool to manage the Database called **psql**. 
          
          
     # psql -U pgsql testdb      # psql -U pgsql testdb
     Welcome to psql 8.0.4, the PostgreSQL interactive terminal.      Welcome to psql 8.0.4, the PostgreSQL interactive terminal.
          
     Type:  \copyright for distribution terms      Type:  \copyright for distribution terms
            \h for help with SQL commands             \h for help with SQL commands
            \? for help with psql commands             \? for help with psql commands
            \g or terminate with semicolon to execute query             \g or terminate with semicolon to execute query
            \q to quit             \q to quit
          
     testdb=#      testdb=#
          
   
 #   PHP and PostgreSQL  #   PHP and PostgreSQL 
   
 You may wish to install the postgres Module for PHP  You may wish to install the postgres Module for PHP 
          
     # pkg_add -v php-pgsql-4.4.1.tgz      # pkg_add -v php-pgsql-4.4.1.tgz
          
   
 Have fun.  Have fun. 
   
 #   Additional Information  #   Additional Information 
   
   * [pkg_add(1)](http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current) Manpage    * [pkg_add(1)](http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current) Manpage 
   * [su(1)](http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-current) Manpage    * [su(1)](http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-current) Manpage 

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb