Installation

Instructions to install PostgreSQL on different platforms.


Google Cloud

According to the documentation on Google Community.


Install PostgreSQL

Follow these steps to install PostgreSQL on your Compute Engine instance.

  1. Open the terminal and enter the ssh command to connect to the Google Compute Instance:

    gcloud compute ssh logistics_dev_01 --zone us-west1-b
    
  2. Update the packages. In the SSH terminal, enter the following command:

    sudo apt-get update
    
  3. Install PostgreSQL, including the PSQL client and server instrumentation:

    sudo apt-get -y install postgresql postgresql-client postgresql-contrib
    

Use PSQL to complete the setup

PostgreSQL created a default user, named “postgres”, during installation. This user doesn’t yet have a password, so you’ll need to set one.

  1. In your SSH terminal, run the root shell:

    sudo -s
    

2.Run PSQL as user postgres, instead of root, accessing the database named postgres:

sudo -u postgres psql postgres
  1. Enter the following command to set the password:

    \password postgres
    

    Passphrase: see KeePass.

  2. When prompted, enter and confirm the password you’ve chosen.

    Important: For any system with an Internet connection, use a strong password to help keep the system secure.

  3. Install the admin pack extension to enable the server instrumentation that you installed earlier. The console prints CREATE EXTENSION when successful:

    CREATE EXTENSION adminpack;
    
  4. Enter q to exit PSQL.

    \q
    
  5. Enter exit to exit the root shell.

    exit
    

Settings

  1. Configure PostgreSQL to accept connections from outside the VM

    Change to the settings directory of PostgreSQL:

    cd /etc/postgresql/15/main
    

    Configure postgresql.conf to listen on external interfaces:

    sudo nano postgresql.conf
    

    Set listen_addresses to ‘*’: By default, listen_addresses is usually set to localhost, meaning PostgreSQL only listens for connections on the localhost (127.0.0.1). To allow connections from external hosts, change this parameter to '*', which tells PostgreSQL to listen on all available network interfaces.

    # To allow connections from external hosts,
    # which tells PostgreSQL to listen on all available network interfaces.
    listen_addresses = '*'
    

    Allow External Connections

    sudo nano pg_hba.conf
    

    Add a line to allow connections from external hosts using password authentication (password).

    # allow connections to all databases from all IP addresses without password authentication
    # customized modification
    host  all       all       0.0.0.0/0        password
    
  2. Configure accounts

    Set passwords to all odoo users, as to use passwords during the login to PostgreSQL, is used by the program TablePlus, here for the user odoo:

    sudo -i
    passwd odoo
    exit
    

macOS

Instructions for the installation and configuration of the PostgreSQL Database on macOS Operating System. This system is used for Development of the odoo System and Python Modules.

  1. Installation

    brew install postgresql
    
  2. Start by launchd

    To have launchd start postgresql now and restart at login:

    brew services start postgresql
    
  3. Stop by launchd

    To stop postgresql:

    brew services stop postgresql
    

  1. Error Message: „psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: FATAL: database “Friedrich” does not exist“

    Create the DB “Friedrich”:

    createdb --owner=Friedrich Friedrich
    

Raspbian

Instructions for the installation and configuration of the PostgreSQL Database on a Raspberry Pi System: Install PostgreSQL on Raspberry Pi. This system is used for testing and deploying purposes.

  1. Installation

    sudo apt-get install postgresql postgresql-contrib libpq-dev
    

  1. Settings: Directories

    • config: /etc/postgresql/9.4/main

    • data: /var/lib/postgresql/9.4/main


  1. Settings: Parameter

    • locale: de_DE.UTF-8

    • Port: 5432


  1. Error Message: „psql: FATAL: role “pi” does not exist“

    Login with User „postgres“ to create user “pi” with psql:

    sudo -i -u postgres
    psql
    createuser pi
    ccreatedb --owner=pi pi
    \q
    

  1. Start and enable Services of PostgreSQL

    Start service PostgreSQL:

    systemctl start postgresql
    

    Enable service PostgreSQL:

    systemctl enable postgresql