PostGreSQL

Aus Info-Theke
Zur Navigation springen Zur Suche springen

Debian

Installation

apt-get install postgresql-9.5 pgadmin3
oder
yum install postgresql-server postgresql-contrib

Ohne Admin-Passwort arbeiten (z.B. temporär)

  • /etc/postgresql/9.5/main/pg_hba.conf
    • host all all 127.0.0.1/32 trust
    • host all all  ::1/128 trust

Benutzer anlegen

  • pgadmin3 aufrufen
    • Login-Rollen: neue Rolle eintragen
  • SQL:
    • CREATE ROLE jonny LOGIN ENCRYPTED PASSWORD 'md582dfb88f80303e0d0e2ffdbdc9e82b64' SUPERUSER INHERIT CREATEDB CREATEROLE NOREPLICATION;

Centos7

Installation

yum install postgresql-server postgresql-contrib

Passwort-Authentifizierung erlauben

Linux-User werden zu PostgreSql-Rollen

vi /var/lib/pgsql/data/pg_hba.conf
# change 
host    all             all             127.0.0.1/32            ident
host    all             all             ::1/128                 ident
#to
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

systemctl restart postgresql

DBMS-Zugriff von außen ermöglichen

  • /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'

Alle Linux-Systeme

Rolle einrichten

sudo -u postgres -i
createuser --interactive
# z.B. hm einrichten
# oder
createuser hm
# Passwort setzen als user postgres:
psql
\password hm

DB erzeugen

  • als User hm:
createdb sale
* oder als User  postgres:
psql
create database owner hm;