Differences between revisions 10 and 12 (spanning 2 versions)
Revision 10 as of 2023-04-02 18:17:11
Size: 2103
Comment:
Revision 12 as of 2023-04-02 18:32:10
Size: 2277
Comment:
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:
For `systemd`-capable systems, [[Linux/Systemd|start and enable]] `postgres.service`.

For [[BSD]] distributions, try:

{{{
pg_ctl -l logfile start
}}}
Line 34: Line 42:
createdb dbname -U postgres createdb dbname --username=postgres
Line 46: Line 54:
createdb dbname -O username createdb dbname --owner=username

PostgreSQL

PostgreSQL is a relational database. It was designed as the successor to Ingress.


Installation

Most Linux and BSD distributions offer a postgresql package that contains the core server components.

Docker container images are also available for all supported versions. The image is available from DockerHub as docker.io/library/postgres (or simply postgres when using docker(1) specifically).


Setup

Before using postgres(1), the database cluster needs to be instantiated.

initdb

For most usecases, this is sufficient. See here for details and more advanced usage.

For systemd-capable systems, start and enable postgres.service.

For BSD distributions, try:

pg_ctl -l logfile start

A database can now be created with the createdb(1) utility. Try:

createdb dbname --username=postgres

To create a user role other than the default postgres user, try:

createuser --interactive

A database can then be created with that alternate user as the owner with:

createdb dbname --owner=username


Configuration

Configurations are primarily made with the configuration file. The file should consist of lines like parameter = value. The = is optional. Anything following a # is a comment.

Configurations can also be made with command line options (such as postgres -c log_connections=on). Parameters use the same names as the configuration file.

In either case, configurations are set at startup. To make a change, either restart the cluster or use pg_ctl reload.

Some parameters can be changed at run time with the SET SQL command.

See here for details on configuration.


Usage

The psql(1) utility is a convenient terminal client. See here for details on how to use it.

The connection string is structured as postgresql://postgres@localhost:5432/dbname?sslmode=disable. Naturally, if the connection should be encrypted, do not include the sslmode=disable component.


CategoryRicottone

PostgreSQL (last edited 2023-04-08 22:37:41 by DominicRicottone)