Skip to main content

Show Helm Chart Values

helm show values dify/dify

Connect to External Database

Supports connecting to PostgreSQL, MySQL, or TiDB as an external database. Here is a general example of external database configuration in Helm chart values:
###################################
# External database (Postgres/MySQL/TiDB)
###################################
externalDatabase:
  enabled: false
  # postgres | mysql | tidb
  engine: "postgres"
  host: "localhost"
  # Default ports: postgres=5432, mysql=3306, tidb=4000
  # Note: when switching engine, remember to update port accordingly
  port: 5432
  user: "postgres"
  password: "#REPLACE_ME#"
  timezone: "UTC"
  databases:
    dify: "dify"
    plugin_daemon: "dify_plugin_daemon"
    enterprise: "enterprise"
    audit: "audit"
  dialectOptions:
    postgres:
      sslMode: "require"
      uriScheme: "postgresql"
      # extras: "options=-c search_path=your-schema -c your-other-option=xxx"
      extras: ""
    mysql:
      # MySQL/TiDB params, e.g. charset=utf8mb4&parseTime=true&loc=UTC
      params: "charset=utf8mb4&parseTime=true&loc=UTC"
      tls: false
Note You need to manually create the required databases before starting Dify.

PostgreSQL

CREATE DATABASE dify;
CREATE DATABASE enterprise;
CREATE DATABASE audit;
-- dify_plugin_daemon will be automatically created when the plugin daemon starts for the first time

MySQL / TiDB

CREATE DATABASE IF NOT EXISTS dify;
CREATE DATABASE IF NOT EXISTS enterprise;
CREATE DATABASE IF NOT EXISTS audit;
-- dify_plugin_daemon will be automatically created when the plugin daemon starts for the first time

Configuration Specification

FieldDescription
engineDatabase type: postgres, mysql, tidb
databasesDatabase name mapping used by each component
dialectOptions.postgresPostgreSQL specific configuration (sslMode, uriScheme, extras, etc.)
dialectOptions.mysqlMySQL/TiDB specific configuration (params, tls, etc.)

Default Ports

EngineDefault Port
postgres5432
mysql3306
tidb4000

Configuration Examples

PostgreSQL (External)

externalDatabase:
  enabled: true
  engine: "postgres"
  host: "postgres.example.com"
  port: 5432
  user: "postgres"
  password: "******"
  databases:
    dify: "dify"
    plugin_daemon: "dify_plugin_daemon"
    extras: ""
  dialectOptions:
    postgres:
      sslMode: "require"

MySQL (External)

externalDatabase:
  enabled: true
  engine: "mysql"
  host: "mysql.example.com"
  port: 3306
  user: "root"
  password: "******"
  databases:
    dify: "dify"
    plugin_daemon: "dify_plugin_daemon"
  dialectOptions:
    mysql:
      params: "charset=utf8mb4&parseTime=true&loc=UTC"

TiDB (External)

externalDatabase:
  enabled: true
  engine: "tidb"
  host: "tidb.example.com"
  port: 4000
  user: "root"
  password: "******"
  databases:
    dify: "dify"
    plugin_daemon: "dify_plugin_daemon"
  dialectOptions:
    mysql:
      params: "charset=utf8mb4&parseTime=true&loc=UTC"