N8n Database Migration Help: SQLite to MySQL, Large Database File

Hello everyone, I’m currently using n8n’s default SQLite database. As my workflows and data have grown, the database file has become quite large (currently around XX MB), causing:

  1. Slow startup times

  2. Large backup files

  3. Concerns about single-file database stability

Current Environment

  • n8n version: 1.102.4

  • Operating system: Linux

  • Database: SQLite (default)

  • Data volume: Approximately 15 workflow records, 3 execution records

Migration Requirements

I want to replace SQLite with MySQL or another more stable database, hoping to:

  1. Preserve existing workflows and data without loss

  2. Improve database performance

  3. Facilitate future maintenance and backup

Issues Encountered

During the migration attempt, I encountered the following difficulties:

  1. JSON field format issues when exporting data from SQLite

  2. MySQL field type mismatches

  3. Abnormal workflow status after migration (old workflows still running but not visible in the backend)

Specific Error Messages

text

Apply to mysql_workfl…

Error 1: JSON parsing errors

Error 2: Field type mismatches

Error 3: Workflow activation shows duplicate warnings

Attempted Solutions

  1. Using sqlite3 to export .sql files and directly import to MySQL :cross_mark:

  2. Using Python scripts to convert data :cross_mark:

  3. Manually modifying table structures :cross_mark:

Help Needed

  1. Recommended Migration Solution: Are there any mature n8n database migration tools or scripts?

  2. Database Choice: MySQL vs PostgreSQL, which is more suitable for n8n?

  3. Migration Steps: Detailed migration operation guide

  4. Problem Resolution: How to handle JSON fields and field type conversion?

  5. Post-Migration Configuration: How to correctly configure n8n to connect to the new database?

Environment Information

  • Database management experience: Yes/No

  • Server management permissions: Yes/No

  • Can restart n8n service: Yes/No

Expected Results

I hope to get a complete, verified migration solution to ensure data security and system stability.

Thank you for your help!

AFAIK, MySQL isn’t that good for data storing, but really good for web app.
For your case, I suggest you use PostgreSQL instead of MySQL (you can use supabase also for that).
Because PostgreSQL give more “flexibility” to working with another SQL database

2 Likes

Thank you for the suggestion! You’re absolutely right about PostgreSQL being a better choice for n8n.

I’ve been struggling with JSON field issues during the SQLite to MySQL migration, which makes sense now - PostgreSQL has much better native JSON support.

Could you share any specific migration guides or tools you’d recommend for SQLite to PostgreSQL migration? Also, any tips on configuring n8n to work optimally with PostgreSQL?

I’m also considering Supabase as you mentioned - would that be easier to set up and manage compared to a self-hosted PostgreSQL instance?

Migrate from SQLite to PostgreSQL: A Step-by-Step Guide
I haven’t trying to migrate from SQLite to PostgreSQL, I only can give you an article for migrating from SQLite to PostgreSQL, maybe it helps.

Basically, Supabase is based on PostgreSQL, and I think it wouldn’t hard to set up if you want to self-host Supabase and Self-Hosting it with Docker, but if your app is still in development or your data wouldn’t too big, you can use supabase cloud instead. The weakness of cloud supabase is the cloud will be paused after 1 week if you’re not doing anything with that, and need to activate it manually with login to supabase dashboard.

But it can be tweaked by adding cron job/scheduler only for example triggering data check

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.