数据库环境变量#
基于文件的配置
您可以为单个变量添加_FILE,以便在单独的文件中提供其配置。详情请参阅将敏感数据保存在单独文件中。
默认情况下,n8n使用SQLite。n8n也支持PostgreSQL。n8n在v1.0版本中移除了对MySQL和MariaDB的支持。
本页概述了为自托管n8n实例配置所选数据库所需的环境变量。
| 变量 | 类型 | 默认值 | 描述 |
|---|---|---|---|
DB_TYPE/ _FILE |
Enum string:sqlite, postgresdb |
sqlite |
The database to use. |
DB_TABLE_PREFIX |
* | - | Prefix to use for table names. |
PostgreSQL#
| 变量 | 类型 | 默认值 | 描述 |
|---|---|---|---|
DB_POSTGRESDB_DATABASE/ _FILE |
String | n8n |
The name of the PostgreSQL database. |
DB_POSTGRESDB_HOST/ _FILE |
String | localhost |
The PostgreSQL host. |
DB_POSTGRESDB_PORT/ _FILE |
Number | 5432 |
The PostgreSQL port. |
DB_POSTGRESDB_USER/ _FILE |
String | postgres |
The PostgreSQL user. |
DB_POSTGRESDB_PASSWORD/ _FILE |
String | - | The PostgreSQL password. |
DB_POSTGRESDB_POOL_SIZE/ _FILE |
Number | 2 |
Control how many parallel open Postgres connections n8n should have. Increasing it may help with resource utilization, but too many connections may degrade performance. |
DB_POSTGRESDB_CONNECTION_TIMEOUT/ _FILE |
Number | 20000 |
Postgres connection timeout (ms). |
DB_POSTGRESDB_SCHEMA/ _FILE |
String | public |
The PostgreSQL schema. |
DB_POSTGRESDB_SSL_ENABLED/ _FILE |
Boolean | false |
Whether to enable SSL. Automatically enabled if DB_POSTGRESDB_SSL_CA, DB_POSTGRESDB_SSL_CERT or DB_POSTGRESDB_SSL_KEY is defined. |
DB_POSTGRESDB_SSL_CA/ _FILE |
String | - | The PostgreSQL SSL certificate authority. |
DB_POSTGRESDB_SSL_CERT/ _FILE |
String | - | The PostgreSQL SSL certificate. |
DB_POSTGRESDB_SSL_KEY/ _FILE |
String | - | The PostgreSQL SSL key. |
DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED/ _FILE |
Boolean | true |
If n8n should reject unauthorized SSL connections (true) or not (false). |
SQLite#
| 变量 | 类型 | 默认值 | 描述 |
|---|---|---|---|
DB_SQLITE_POOL_SIZE |
Number | 0 |
Controls whether to open the SQLite file in WAL mode or rollback journal mode. Uses rollback journal mode when set to zero. When greater than zero, uses WAL mode with the value determining the number of parallel SQL read connections to configure. WAL mode is much more performant and reliable than the rollback journal mode. |
DB_SQLITE_VACUUM_ON_STARTUP |
Boolean | false |
Runs VACUUM operation on startup to rebuild the database. Reduces file size and optimizes indexes. This is a long running blocking operation and increases start-up time. |