Migrating from H2 to MySQL with Docker on Linux


#1

Hi all,

I am new in the linux environment but I would like to setup Metabase in a production environment following this resource: https://www.metabase.com/docs/latest/operations-guide/start.html#migrating-from-using-the-h2-database-to-mysql-or-postgres

However, I am stuck at step 3 of data migration where I succeed in setting up the environmental variables but, I get stuck when I run the command:

.sudo docker run -e MB_DB_TYPE=mysql -e MB_DB_DBNAME=metabase_db -e MB_DB_PORT=3306 -e MB_DB_USER=metabase_user -e MB_DB_PASS=Password1 -e MB_DB_HOST=192.168.170.112 -p 3006:3000 --name metan metabase/metabase

which gives the following error:

11-02 12:06:29 ERROR metabase.driver :: Failed to connect to database: Timed out after 5000 milliseconds. 11-02 12:06:29 ERROR metabase.core :: Metabase Initialization FAILEDjava.lang.AssertionError: Assert failed: Unable to connect to Metabase mysql DB.(binding [allow-potentailly-unsafe-connections true] (require (quote metabase.driver)) ((resolve (quote metabase.driver/can-connect-with-details?)) engine details))

This is how I backed up my db:
sudo docker cp metabase:/metabase.db /tmp/metabase

I set my environment variables in the metabase process:
sudo docker exec -i 3897df43a43c /bin/sh

Here’s my environment variables:
export MB_DB_TYPE=mysql
export MB_DB_DBNAME=metabase_db
export MB_DB_PORT=3306
export MB_DB_USER=…
export MB_DB_PASS=…
export MB_DB_HOST=localhost

What am I doing wrong for metabase not to connect with MySQL?