Technical article 127034

How do I install and start to use PostgreSQL?

OpenServer 6.0.0OpenServer 5.0.7UnixWare 7.1.4

Written · Last revised

Problem

How do I install and start to use PostgreSQL?

Solution

For OpenServer 5.0.7:
--------------------
Please ensure the latest Maintenance is installed for this product.
See:
http://www.sco.com/support/update/download/osr507list.html

For example, the Supplement CD 5 contains:

PostgreSQL Database Management System 8.1.4
https://ftp.scoexpert.com/openserver5/507/iso/osr507suppcd5/osr507suppcd5.html
For UnixWare 7.1.4:
------------------
Please ensure the latest Maintenance is installed for this product.
See:
http://www.sco.com/support/update/download/product.php?pfid=1&prid=6

For example, Maintenance Pack 4 contains version 8.2.6-01.

For OpenServer 6.0.0:
--------------------
Step 1- Installation:

Please ensure that the latest Maintenance is installed first from:

http://www.sco.com/support/update/download/product.php?pfid=12&prid=20

In this example, the following version was installed v8.2.3Dc from:

http://www.sco.com/support/update/download/release.php?rid=338

and the installation instructions provided were followed.

Follow the
Run:
# mkdev pgsql

When prompted enter the UID of the new 'postgres' user you want to run PostgreSQL, for example 201.

Once created the following menu will be displayed and follow the prompts below:

-----
PostgreSQL Configuration Program
1. Configure PostgreSQL
2. View current PostgreSQL configuration

Select an option or enter q to quit: 1

PostgreSQL Configuration Menu
1.  Enable PostgreSQL
2.  Disable PostgreSQL
3.  Start PostgreSQL postmaster process
4.  Stop PostgreSQL postmaster process
    (after all clients have disconnected)
5.  Stop PostgreSQL postmaster process NOW
6.  Restart PostgreSQL postmaster process
    (after all clients have disconnected)
7.  Restart PostgreSQL postmaster process NOW
8.  Set PostgreSQL database owner
9.  Set PostgreSQL database directory

Select an option or enter q to return to the main menu: 1

PostgreSQL will be enabled
The directory /usr/postgres/data does not exist.
Create directory '/usr/postgres/data'? (y/n) y

The directory /usr/postgres/data does not contain a valid database, and the directory should be initialized.

Initialize databases in /usr/postgres/data? (y/n) y

The files belonging to this database system will be owned by user "postgres".

This user must also own the server process.

The database cluster will be initialized with locale C.

fixing permissions on existing directory
/usr/postgres/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ...
32MB/204800
creating configuration files ... ok
creating template1 database in /usr/postgres/data/base/1
... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the -A option the next time you run initdb.

Success. You can now start the database server using:

    /usr/bin/postgres -D /usr/postgres/data
or
    /usr/bin/pg_ctl -D /usr/postgres/data -l logfile start
PostgreSQL Configuration Program
1. Configure PostgreSQL
2. View current PostgreSQL configuration

Select an option or enter q to quit: 2

Current PostgreSQL configuration and status:

PostgreSQL is currently running PostgreSQL is currently enabled The postmaster process will run as user 'postgres' The database located in the directory /usr/postgres/data

-----

You can now quit from the "mkdev pqsql" script when prompted.

- At the prompt the command to control PostgreSQL is "pgsql":

# pgsql
Usage: pgsql [ start | stop | enable | disable | query |
status | restart ]
# pgsql status
postmaster is currently running.
postmaster is enabled.

bash-3.2# pgsql enable Enabling postmaster ... done. Starting postmaster ... done.

bash-3.2# pgsql start
postmaster is already running.

- Once started you should see the following processes running:

# ps -ef
postgres  4163     1  0 14:05:13 ttyp0        00:00:00
/usr/bin/postgres -D /usr/postgres/data
postgres  4168  4163  0 14:05:14 ?            00:00:00
/usr/bin/postgres -D /usr/postgres/data
postgres  4169  4163  0 14:05:14 ?            00:00:00
/usr/bin/postgres -D /usr/postgres/data

- To change any particular PostgreSQL configuration then use the conf file:

cd /usr/postgres/data
-rw-------    1 postgres nogroup  15313 May 30 14:04
postgresql.conf

- To use PostgreSQL initially you can't run it as root:

bash-3.2# psql
psql: FATAL:  database "root" does not exist

bash-3.2# createdb test createdb: could not connect to database postgres: FATAL: role "root" does not exist

- You need to be logged in as the 'postgres' user:

# su - postgres
$ pwd
/usr/postgres
$ createdb test
CREATE DATABASE
$ psql test
Welcome to psql 8.2.3, the PostgreSQL interactive
terminal.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
test=#

- To create your first table then use:

http://osr600doc.xinuos.com/en/DB_postgresql/tutorial-table.html

- To populate the table then use:

http://osr600doc.xinuos.com/en/DB_postgresql/tutorial-populate.html

This also includes how to import from a comma delimited file.

See also

http://osr600doc.xinuos.com/en/DB_postgresql/index.html

From the Xinuos technical article database, record 127034. Reproduced with permission. The original is at www.sco.com/ta/127034, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.