.. _postgresql_installation: Installation ============ Instructions to install PostgreSQL on different platforms. | .. _chapter_google_cloud_postgresql_installation: 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: .. code-block:: shell gcloud compute ssh logistics_dev_01 --zone us-west1-b 2. Update the packages. In the SSH terminal, enter the following command: .. code-block:: shell sudo apt-get update 3. Install PostgreSQL, including the PSQL client and server instrumentation: .. code-block:: shell 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: .. code-block:: shell sudo -s 2.Run PSQL as user postgres, instead of root, accessing the database named postgres: .. code-block:: shell sudo -u postgres psql postgres 3. Enter the following command to set the password: .. code-block:: shell \password postgres Passphrase: see :keepass:`KeePass<>`. 4. 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. 5. Install the admin pack extension to enable the server instrumentation that you installed earlier. The console prints CREATE EXTENSION when successful: .. code-block:: shell CREATE EXTENSION adminpack; 6. Enter \q to exit PSQL. .. code-block:: shell \q 7. Enter exit to exit the root shell. .. code-block:: shell exit **Settings** 1. Configure PostgreSQL to accept connections from outside the VM Change to the settings directory of PostgreSQL: .. code:: cd /etc/postgresql/15/main Configure ``postgresql.conf`` to listen on external interfaces: .. code:: 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. .. code:: # To allow connections from external hosts, # which tells PostgreSQL to listen on all available network interfaces. listen_addresses = '*' Allow External Connections .. code:: sudo nano pg_hba.conf Add a line to allow connections from external hosts using password authentication (``password``). .. code:: # 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``: .. code:: 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 .. code-block:: shell brew install postgresql 2. Start by launchd To have launchd start postgresql now and restart at login: .. code-block:: shell brew services start postgresql 3. Stop by launchd To stop postgresql: .. code-block:: shell brew services stop postgresql | 4. Error Message: „psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: database "Friedrich" does not exist“ Create the DB "Friedrich": .. code-block:: shell 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 .. code-block:: shell sudo apt-get install postgresql postgresql-contrib libpq-dev | 2. Settings: Directories - config: /etc/postgresql/9.4/main - data: /var/lib/postgresql/9.4/main | 3. Settings: Parameter - locale: de_DE.UTF-8 - Port: 5432 | 4. Error Message: „psql: FATAL: role "pi" does not exist“ Login with User „postgres“ to create user "pi" with psql: .. code-block:: shell sudo -i -u postgres psql createuser pi ccreatedb --owner=pi pi \q | 5. Start and enable Services of PostgreSQL Start service PostgreSQL: .. code-block:: shell systemctl start postgresql Enable service PostgreSQL: .. code-block:: shell systemctl enable postgresql