PostgreSQL

From Void Linux Wiki
Jump to: navigation, search

PostgreSQL is an open-source object-relational database system.

Installation

Install the postgresql package, which is the server component.

# xbps-install -S postgresql

It will also create a system user called postgres.

To install the client component, you need to install the postgresql-client package.

# xbps-install -S postgresql-client

Initial configuration

In order to use the database system, the database cluster must be initialized. To do this, you must first switch to the postgres user:

$ sudo -u postgres -i

Or by using su:

$ su
# su -l postgres

After that, you can create the cluster by running the following command:

[postgres]$ initdb -D '/var/lib/postgresql/data'

An output will be printed on the screen during and after the execution.

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 "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok 

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

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgresql/ -l logfile start

If the output is similar to this, the operation was successful.

Finally, you can start the postgres service.

# ln -s /etc/sv/postgresql /var/service

Usage

TODO