Metabase connects to H2 even when MySQL is specified

I am trying to have Metabase use Maria DB as the application Database.
I am running metabase in a docker container and have specified the necessary environment variables in the docker compose as follows:

environment:
      - MD_DB_TYPE=mysql
      - MB_DB_DBNAME=metabase
      - MB_DB_PORT=3306
      - MB_DB_USER=metabase
      - MB_DB_PASS=<password>
      - MB_DB_HOST=<DB Host>

And in the container, metabase is started by running the jar:

java -jar metabase.jar

Still, in the logs, I see metabase is starting up a H₂ database and doesn't connect to the Maria DB table.

metabase       | 2022-01-18 22:53:23,721 WARN db.env :: WARNING: Using Metabase with an H2 application database is not recommended for production deployments. For production deployments, we highly recommend using Postgres, MySQL, or MariaDB instead. If you decide to continue to use H2, please be sure to back up the database file regularly. For more information, see https://metabase.com/docs/latest/operations-guide/migrating-from-h2.html

I am even printing the environment variables before the java command is run to see if the variables are set properly, and I can see the following:

metabase       | HOSTNAME=20b98bbbb485
metabase       | SHLVL=0
metabase       | HOME=/root
metabase       | MB_DB_DBNAME=metabase
metabase       | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
metabase       | MB_DB_PASS=<password>
metabase       | LANG=C.UTF-8
metabase       | QEMU_CPU=arm1176
metabase       | DEBIAN_FRONTEND=noninteractive
metabase       | MB_DB_HOST=<DB Host>
metabase       | MB_DB_USER=metabase
metabase       | UDEV=off
metabase       | LC_ALL=C.UTF-8
metabase       | JAVA_HOME=/docker-java-home
metabase       | PWD=/
metabase       | MD_DB_TYPE=mysql
metabase       | MB_DB_PORT=3306

This seems like a bug as I would expect that with these env variables set, it should connect to MySQL.

I am using the latest versions of both Metabase (0.41.6) and Maria DB (10.5.13) on a Balena openjdk base container (debian based).

Can someone help me with this?

[Update 1]

Looking at this link, Running Metabase On Debian, I created the /etc/default/metabase file and then ran the jar file.
It still picks up the H2 database.

Here is what I have in the file:

# cat /etc/default/metabase
MD_DB_TYPE=mysql
MB_DB_DBNAME=metabase
MB_DB_PORT=3306
MB_DB_USER=metabase
MB_DB_PASS=<password>
MB_DB_HOST=<DB Host>

[Update 2]

Now, I went into the container (with the server stopped) and manually ran export for all the variables.

root@e8a2ed78b1aa:/# export MD_DB_TYPE=mysql
root@e8a2ed78b1aa:/# export MB_DB_DBNAME=metabase
root@e8a2ed78b1aa:/# export MB_DB_PORT=3306
root@e8a2ed78b1aa:/# export MB_DB_USER=metabase
root@e8a2ed78b1aa:/# export MB_DB_PASS=<password>
root@e8a2ed78b1aa:/# export MB_DB_HOST=<DB Host>

And then ran the jar file. Still the same issue. It picks up H₂ database. This definitely seems like a bug. Can someone confirm and let me know if I'm setting anything wrong?

Hi @johnny
I'm quite sure there isn't any bugs, but it's just incorrect setup.
Notice the "D" in MD_DB_TYPE - should be MB_DB_TYPE

1 Like

Lol. I'm super embarrassed now. I couldn't see, even when it was starting at me all this time! :sweat_smile:
Thank you for finding it. I kept on copying and pasting from what I had without retyping it and so everything had the issue!

Thank you, @flamber. It is working now :man_facepalming: