Set up PostgreSQL as MLflow’s Backend Store

You can follow the below steps to set up PostgreSQL and configure it as the backend store for MLflow.


Steps to Setup

  1. Install PostgreSQL.

On Ubuntu/Debian:

sudo apt update sudo apt install postgresql postgresql-contrib

On CentOS/RHEL:

sudo yum install postgresql-server postgresql-contrib sudo postgresql-setup initdb sudo systemctl start postgresql sudo systemctl enable postgresql
  1. Switch to the Postgres user and enter the PostgreSQL shell.

sudo -i -u postgres psql
  1. Create a database and user for MLflow.

CREATE DATABASE mlflow; CREATE USER mlflow WITH ENCRYPTED PASSWORD 'mlflow'; GRANT ALL PRIVILEGES ON DATABASE mlflow TO mlflow; \q

Replace 'your_password' with a strong password.

  1. Configure PostgreSQL to allow remote connections (optional)

  2. Edit the PostgreSQL config file postgresql.conf to listen on all IPs:

sudo nano /etc/postgresql/<version>/main/postgresql.conf

Find the line:

Find the line:

Uncomment and change it to:

listen_addresses = '*'
  1. Edit pg_hba.conf to allow your MLflow server IP (or all IPs):

sudo nano /etc/postgresql/<version>/main/pg_hba.conf
  1. Add this line at the end (replace <mlflow_server_ip> with your MLflow server IP):

host mlflow_db mlflow_user <IP Address> md5
  1. Restart PostgreSQL:

sudo systemctl restart postgresql


  Last updated