Installing and Configuring PostgreSQL for Mango | Radix IoT

Installing and Configuring PostgreSQL for Mango

๐Ÿงฉ Installing and Configuring PostgreSQL for Mango

This guide provides detailed steps to install and configure PostgreSQL for use with Mango OS. You will install PostgreSQL, create a dedicated Mango database and user, and validate Mangoโ€™s connection to ensure data is written properly.


๐Ÿ” Overview

  • Install and initialize PostgreSQL
  • Secure the default postgres role
  • Create a mango database and user
  • Verify permissions and connectivity
  • Point Mango to PostgreSQL via mango.properties

๐Ÿ›  Part 1: PostgreSQL Installation

  1. Switch to Superuser
    sudo su
    
  2. Install PostgreSQL Server and Tools
    dnf install postgresql-server postgresql-contrib
    
  3. Initialize the Database
    postgresql-setup --initdb
    
  4. Enable and Start PostgreSQL Service
    systemctl enable postgresql
    systemctl start postgresql
    
  5. Verify Installation
    psql --version
    

๐Ÿ” Part 2: Secure PostgreSQL and Set Password

  1. Switch to the PostgreSQL User
    su - postgres
    
  2. Open the PostgreSQL Shell
    psql
    
  3. Set the Password for the postgres Role
    \password postgres;
    

    Choose a strong password and store it securely (e.g., Keeper). Exit when finished:

    \q
    

๐Ÿงฑ Part 3: Create Database and User for Mango

  1. Log in as postgres
    su - postgres
    psql
    
  2. Create Mango Database and Role
    CREATE DATABASE mango;
    CREATE ROLE mango WITH LOGIN PASSWORD 'putthepasswordhere';
    GRANT ALL PRIVILEGES ON DATABASE mango TO mango;
    \q
    
  3. Optional: Adjust pg_hba.conf for Local Access

    Edit the file (path may vary by distro; on RHEL-family itโ€™s typically /var/lib/pgsql/data/pg_hba.conf):

    vi /var/lib/pgsql/data/pg_hba.conf
    

    Ensure the following line allows local password authentication:

    local   all             all                                     md5
    
  4. Reload PostgreSQL
    systemctl restart postgresql
    

โœ… Part 4: Verify Database Permissions

  1. Test Login with Mango User
    psql -U mango -d mango -W
    
  2. Run Basic SQL Commands
    CREATE TABLE test_table (test_id INT);
    INSERT INTO test_table (test_id) VALUES (1);
    SELECT * FROM test_table;
    DROP TABLE test_table;
    \q
    

    If all commands succeed, the Mango user has proper privileges.


๐Ÿ” Part 5: Connect Mango to PostgreSQL

  1. Edit the mango.properties file and update the database connection settings:
    db.type=postgres
    db.url=jdbc:postgresql://localhost:5432/mango
    db.username=mango
    db.password=putthepasswordhere
    
  2. Start Mango
    systemctl start mango
    
  3. Verify Mango is Writing to PostgreSQL
    psql -U mango -d mango -W
    SELECT * FROM events LIMIT 5;
    

    โœ… You should see at least one startup event listed.


๐Ÿงพ Summary

  • Installed and initialized PostgreSQL
  • Secured the default postgres role
  • Created the mango database and user
  • Connected Mango to PostgreSQL
  • Verified data writes

๐Ÿ”— References


    • Related Articles

    • Mango v5 Minimum System Requirements

      Overview Mango by Radix IoT is a browser-based, cross-platform application for monitoring, controlling, and analyzing data from sensors, PLCs, subsystems, databases, and web services. Performance depends on the number of data points, configuration, ...
    • Mango v5.4.x - Windows Installation

      ? Overview Installing Mango Automation on a Windows computer is straightforward. This guide walks you through: Setting up Java JDK 17 (Azul Zulu OpenJDK) Downloading and installing Mango Running Mango from the command line Configuring Mango as a ...
    • Installing Mango Automation via Docker on Ubuntu

      ? Overview This guide explains how to install and run Mango Automation as a Docker container on an Ubuntu host. It covers: Installing Docker Pulling and running the Mango image Editing mango.properties inside the container Viewing Mango log files ...
    • Configuring BACnet/IP data source and BACnet publisher in Mango

      ? Overview This guide outlines the steps to configure BACnet/IP communication in Mango OS, including setting up a BACnet Local Device, creating a BACnet/IP Data Source, and publishing points via a BACnet Publisher. These steps allow Mango to ...
    • Configuring Modbus IP Data Source in Mango

      ? Overview The Modbus IP data source in Mango OS is used to gather data from Modbus-compatible devices over an IP network. These devices can reside on a local network, an intranet, or even the public internet. The data source operates by polling the ...