Top Menu

Jump to content
Home
    • Projects
    • Work packages
    • News
    • Getting started
    • Introduction video
      Welcome to OpenProject
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Professional support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Create a new account
      Forgot your password?

Side Menu

  • Overview
  • Activity
  • Wiki
    • Table of contents
      • Expanded. Click to collapseCollapsed. Click to showWiki
        • Hierarchy leafModalität
        • Expanded. Click to collapseCollapsed. Click to showThemen
          • Hierarchy leaf00) Installation GNU/Linux in Virtualbox
          • Hierarchy leaf01) GNU/Linux Basics & Bash commandos
          • Hierarchy leaf02) Schulinternes APT Repository
          • Hierarchy leaf03) Fernwartung über SSH
          • Hierarchy leaf04) Prozesse und Systemd
          • Hierarchy leaf05) UFW
          • Hierarchy leaf06) MySQL
          • Hierarchy leaf07) Abfragen an die Mondial Datenbank
          • Hierarchy leaf08) PostgreSQL
          • Hierarchy leaf10) Crontab
          • Hierarchy leaf11) Wordpress
          • Expanded. Click to collapseCollapsed. Click to show12) Docker
            • Hierarchy leaf00) MySQL - Volumes - Ports ...
            • Hierarchy leaf01) PostgreSQL
            • Hierarchy leaf02) Docker-Compose
You are here:
  • Wiki
  • Themen
  • 08) PostgreSQL

Content

08) PostgreSQL

  • More
    • Print
    • Table of contents

PostgreSQL installieren

Installiere bitte postgres mit sudo apt-get install postgresql-10

Mittels psql kann direkt mit der Datenbank kommuniziert werden. die Anmeldung funktioniert aber nur mit dem postgres Benutzer. Wechsle mittels su postgres zu diesem Benutzer.

sudo su postgres
#Benutzer anlegen
echo "CREATE USER mondial with PASSWORD 'pwd';" | psql
#Datenbank anlegen
echo "CREATE DATABASE mondial;" | psql
#Berechtigung setzen
echo "GRANT ALL PRIVILEGES ON DATABASE mondial TO mondial;" | psql;

Mondial Datenbank importieren

  • Schema
  • Data
sudo su postgres
cd /tmp/
wget https://www.dbis.informatik.uni-goettingen.de/Mondial/mondial-schema.psql
wget https://www.dbis.informatik.uni-goettingen.de/Mondial/mondial-inputs.psql
cat mondial-schema.psql | psql -d mondial
cat mondial-inputs.psql | psql -d mondial
echo "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO mondial;" | psql -d mondial;

Datenbank von außen verfügbar machen

Achtung, dies machen wir hier nur für Unterrichtszwecke, eine Datenbank ist nur im seltensten Fall für jede externe IP Verfügbar

Editiere die Datei /etc/postgresql/10/main/postgresql.conf:

Ersetze Zeile: #listen_addresses = 'localhost' durch listen_addresses = '*'

Editiere die Datei /etc/postgresql/10/main/pg_hba.conf:

  • Datenbank ist für alle verfügbar: host all mondial 0.0.0.0/0 md5
  • Datenbank ist nur für 192.168.0.10 verfügbar: host all mondial 192.168.0.10/32 md5

Teste die Datenbankverbindung von Windows aus mit pgAdmin.

Achtung

  • Verwendest du in Virtualbox die Netzwerkverbindung NAT so musst du den PostgreSQL Port (5432) freischalten.
  • Ist ufw aktiviert, so muss der Port ebenafalls freigeschaltet werden.
Loading...