I’m trying to set up a Docker container for n8n that links to a Docker container of MySQL. I can get the MySQL set up and even link into it through a bridge from another container, but when I try to create an n8n container, the system waits for a few seconds and then closes the container. The next time I try to create the container it says the last session crashed.
The closest thing to an error message I am seeing is:
Initializing n8n process
Last session crashed
I should explain that I am new to docker, n8n, and MySQL and it is a miracle I even got this far. Please explain things in a newbie-friendly way if you could.
docker network create --driver bridge dbnet
docker network inspect dbnet
docker pull mysql/mysql-server:5.7
docker run --name mysql \
--env MYSQL_ROOT_PASSWORD=<PASSWORD> \
--env MYSQL_ROOT_HOST=172.0.0.0/255.0.0.0 \
--env MYSQL_DATABASE=<DATABASE> \
--volume $pwd/mysql-data:/var/lib/mysql \
--network dbnet \
mysql/mysql-server:5.7
mysql -u root -p
CREATE USER '[user]'@'localhost' IDENTIFIED WITH mysql_native_password BY '[password]';
GRANT ALL PRIVILEGES ON *.* TO '[user]'@'%' IDENTIFIED BY '[password]' with grant option;
docker run --rm -it --name n8n -p 5678:5678 \
-e DB_TYPE=mysqldb -e DB_MYSQLDB_DATABASE=n8n \
-e DB_MYSQLDB_HOST=<DBNET IP> \
-e DB_MYSQLDB_PORT=3306 \
-e DB_MYSQLDB_USER=<USER> \
-e DB_MYSQLDB_PASSWORD=<PASSWORD> \
--network dbnet \
-v ~/.n8n:/home/node/.n8n n8nio/n8n \
n8n start
Running n8n via [Docker, n8n, MySQL5.7]:
I’m using MySQL 5.7 due to an issue with MySQL encoding the root password in a way that my other container cannot read.
I am sorry to hear you’re having trouble. Can you share the output you are seeing before the n8n container crashes? This should hopefully have a few more details.
On a different note, I think we are considering dropping support for MySQL as an n8n backend database at some point. So you might want to consider using PostgreSQL instead. n8n/docker/compose/withPostgres at master · n8n-io/n8n · GitHub would have an example configuration for docker compose that should help getting started with this database.
Please don’t drop support for MySQL as backend database. We use it extensively. Just leave it as an option. Not everyone is familiar with PostgreSQL etc.
And it’s not that we have it on a single node. We use MySQL that is part of a failover cluster etc. We can’t spin for example a PostgreSQL node because then we have to create a plan for a cluster network too etc.
Hi @Mulen, tbf I don’t have any details and am not familiar with the exact plans. It’s just something I heard being discussed. I imagine there’d definitely be plenty of time to prepare if this happens at all (and there definitely won’t be a forced upgrade, so you can always continue using an existing setup).
The main argument against was that supporting MySQL costs a lot of time time and effort on writing and debugging migrations, especially around behavior specific to MySQL. There are pro arguments as well of course.
This is all I saw. The n8n container didnt give any other output. That being said, I will try to switch to a postgreSQL setup and see if that works. Luckily Im still in the early phases of this project so nothing is set in stone.
Having a bit of the same issue here with MySQL. I am trying to move to a new sql server - but I can not make it play nice at all…
kubectl logs -n n8nautomation n8napp-79994d8b74-5dmnr
2023-01-27T23:39:44.378Z | info | Initializing n8n process “{ file: ‘start.js’, function: ‘run’ }”
That is the only event at all in the logs - just dies - even with logging set to debug. Interestinly enough, I get the same error if I have the incorrect username on the current server - so my best guess is something is miss typed; but I can not find it at all for the life of me. I really wish there was a way to get more from the crash event.
Mariadb on azure (10.3) is requiring [email protected] in the username feild for most divers… Like it wasn’t required for phpipam or ombi, but was for this and a couple of other things… Errors varied, but the total crash was the strangest