2019-09-22 09:29:03 -07:00
# Database
2020-04-15 06:36:15 -07:00
By default, n8n uses SQLite to save credentials, past executions, and workflows. However,
n8n also supports MongoDB and PostgresDB.
2019-09-22 09:29:03 -07:00
2020-03-21 10:32:26 -07:00
## Shared Settings
The following environment variables get used by all databases:
- `DB_TABLE_PREFIX` (default: '') - Prefix for table names
2019-09-22 09:29:03 -07:00
## MongoDB
2020-04-15 06:36:15 -07:00
!> **WARNING** : Use PostgresDB, if possible! MongoDB has problems saving large
amounts of data in a document, among other issues. So, support
2019-09-22 09:29:03 -07:00
may be dropped in the future.
2020-04-15 06:36:15 -07:00
To use MongoDB as the database, you can provide the following environment variables like
in the example below:
2019-09-22 09:29:03 -07:00
- `DB_TYPE=mongodb`
- `DB_MONGODB_CONNECTION_URL=<CONNECTION_URL>`
Replace the following placeholders with the actual data:
- MONGO_DATABASE
- MONGO_HOST
- MONGO_PORT
- MONGO_USER
- MONGO_PASSWORD
```bash
export DB_TYPE=mongodb
export DB_MONGODB_CONNECTION_URL=mongodb://MONGO_USER:MONGO_PASSWORD@MONGO_HOST:MONGO_PORT/MONGO_DATABASE
n8n start
```
## PostgresDB
2020-04-15 06:36:15 -07:00
To use PostgresDB as the database, you can provide the following environment variables
2019-09-22 09:29:03 -07:00
- `DB_TYPE=postgresdb`
- `DB_POSTGRESDB_DATABASE` (default: 'n8n')
- `DB_POSTGRESDB_HOST` (default: 'localhost')
- `DB_POSTGRESDB_PORT` (default: 5432)
- `DB_POSTGRESDB_USER` (default: 'root')
- `DB_POSTGRESDB_PASSWORD` (default: empty)
2020-03-17 22:04:53 -07:00
- `DB_POSTGRESDB_SCHEMA` (default: 'public')
2019-09-22 09:29:03 -07:00
```bash
export DB_TYPE=postgresdb
export DB_POSTGRESDB_DATABASE=n8n
export DB_POSTGRESDB_HOST=postgresdb
export DB_POSTGRESDB_PORT=5432
export DB_POSTGRESDB_USER=n8n
export DB_POSTGRESDB_PASSWORD=n8n
2020-03-17 22:04:53 -07:00
export DB_POSTGRESDB_SCHEMA=n8n
2019-09-22 09:29:03 -07:00
n8n start
```
2020-04-14 10:54:11 -07:00
## MySQL / MariaDB
2020-02-10 08:27:58 -08:00
2020-04-15 06:36:15 -07:00
The compatibility with MySQL/MariaDB has been tested. Even then, it is advisable to observe the operation of the application with this database as this option has been recently added. If you spot any problems, feel free to submit a burg report or a pull request.
2020-02-10 08:27:58 -08:00
To use MySQL as database you can provide the following environment variables:
2020-04-14 10:54:11 -07:00
- `DB_TYPE=mysqldb` or `DB_TYPE=mariadb`
2020-02-10 08:27:58 -08:00
- `DB_MYSQLDB_DATABASE` (default: 'n8n')
- `DB_MYSQLDB_HOST` (default: 'localhost')
- `DB_MYSQLDB_PORT` (default: 3306)
- `DB_MYSQLDB_USER` (default: 'root')
- `DB_MYSQLDB_PASSWORD` (default: empty)
```bash
2020-02-11 21:26:43 -08:00
export DB_TYPE=mysqldb
2020-02-10 08:27:58 -08:00
export DB_MYSQLDB_DATABASE=n8n
export DB_MYSQLDB_HOST=mysqldb
export DB_MYSQLDB_PORT=3306
export DB_MYSQLDB_USER=n8n
export DB_MYSQLDB_PASSWORD=n8n
n8n start
```
2019-09-22 09:29:03 -07:00
## SQLite
2020-04-15 06:36:15 -07:00
This is the default database that gets used if nothing is defined.
2019-09-22 09:29:03 -07:00
The database file is located at:
`~/.n8n/database.sqlite`
## Other Databases
2020-04-15 06:36:15 -07:00
Currently, only the databases mentioned above are supported. n8n internally uses
[TypeORM ](https://typeorm.io ), so adding support for the following databases
2019-09-22 09:29:03 -07:00
should not be too much work:
- CockroachDB
- Microsoft SQL
- Oracle
2020-04-15 06:36:15 -07:00
If you cannot use any of the currently supported databases for some reason and
you can code, we'd appreciate your support in the form of a pull request. If not, you can request
for support here:
2019-09-22 09:29:03 -07:00
[https://community.n8n.io/c/feature-requests/cli ](https://community.n8n.io/c/feature-requests/cli )