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.htmlFor example, the Supplement CD 5 contains:
PostgreSQL Database Management System 8.1.4https://ftp.scoexpert.com/openserver5/507/iso/osr507suppcd5/osr507suppcd5.htmlFor 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=6For 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=20In this example, the following version was installed v8.2.3Dc from:
http://www.sco.com/support/update/download/release.php?rid=338and the installation instructions provided were followed.
Follow theRun:# mkdev pgsqlWhen 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 Program1. Configure PostgreSQL
2. View current PostgreSQL configurationSelect an option or enter q to quit: 1
PostgreSQL Configuration Menu1. 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 directorySelect an option or enter q to return to the main menu: 1
PostgreSQL will be enabledThe directory /usr/postgres/data does not exist.Create directory '/usr/postgres/data'? (y/n) yThe directory /usr/postgres/data does not contain a valid database, and the directory should be initialized.
Initialize databases in /usr/postgres/data? (y/n) yThe 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 ... okWARNING: 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 startPostgreSQL Configuration Program1. Configure PostgreSQL
2. View current PostgreSQL configurationSelect 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 -efpostgres 4163 1 0 14:05:13 ttyp0 00:00:00
/usr/bin/postgres -D /usr/postgres/datapostgres 4168 4163 0 14:05:14 ? 00:00:00
/usr/bin/postgres -D /usr/postgres/datapostgres 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 existbash-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 quittest=#- 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.htmlThis also includes how to import from a comma delimited file.
See also
http://osr600doc.xinuos.com/en/DB_postgresql/index.html