PostgreSQL

<< Click to Display Table of Contents >>

Navigation:  Linux - Ubuntu 24.04 >

PostgreSQL

Einführung

In diesem Abschnitt sollen die ersten Punkte im Umgang mit PostgreSQL beschrieben werden. Bis zur Version 22.04 ist PostgreSQL 14 von Interesse. Danach kommt PostgreSQL16 und später 18 in den LTS Versionen.

The Home Page of PostgreSQL

Installation

Man beachte das Installationsscript unter "pas".

PostgreSQL - Treiber/Linux

Wenn man nur die Entwicklungsbibliothek und den C-Treiber benötigt, dann reicht das folgende Script:

 

sudo apt-get install libpq-dev

 

PostgreSQL - Download

Einer der Hauptanlaufpunkte für Downloads für Windows (auch für ODBC Treiber) ist die Website oder für hier nur für ODBC (Windows).

PostgreSQL - Installation

The next installation is PostgreSQL. Before that you should install additional prerequisites:

sudo apt-get install gnupg2

One adds new installation sources via

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

 

Update the available packages and install PostgreSQL via:

sudo apt -y update

sudo apt -y install postgresql postgresql-server-dev postgresql-client 

and check the installed version via:

sudo -u postgres psql -c "SELECT version();"

 

Do not do anything with this database yet, especially login into the database from outside.

Reference

PostgreSQL - Development Support

Für die Programmierung unter Python sollte das Paket "psycopg2" installiert werden via "pip3 install psycop2". For this to work you have to install the development support for PostgreSQL prio this step (postgresql-server-dev-14).

PostgreSQL - Neuer Benutzer hinzufügen, neue Datenbank anlegen

If you know, that you need a new user, then now its time to create them. We want to create a superuser and a normal user:

sudo -u postgres psql

CREATE ROLE [superusername] WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD '[password]';

create database [dbname];

create user [normalusername] with encrypted password '[password2]';

grant all privileges on database  [dbname] to [normalusername];

 

 

Reference