Migrating from H2 to MySQL - doesn't take?

Diagnostic Info:

{
  "browser-info": {
    "language": "en-US",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Safari/605.1.15",
    "vendor": "Apple Computer, Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.8+10-post-Ubuntu-0ubuntu120.04",
    "java.vendor": "Ubuntu",
    "java.vendor.url": "https://ubuntu.com/",
    "java.version": "11.0.8",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.8+10-post-Ubuntu-0ubuntu120.04",
    "os.name": "Linux",
    "os.version": "5.4.0-51-generic",
    "user.language": "en",
    "user.timezone": "America/New_York"
  },
  "metabase-info": {
    "databases": [
      "mysql"
    ],
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "1.4.197 (2018-03-18)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "1.4.197 (2018-03-18)"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2020-09-15",
      "tag": "v0.36.6",
      "branch": "release-0.36.x",
      "hash": "cb258fb"
    },
    "settings": {
      "report-timezone": "US/Eastern"
    }
  }
}

I thought I just managed to migrate to MySQL. I lost the terminal output from ā€˜java -jar metabase.jar load-from-h2 /opt/metabase/metabase.dbā€™ but it ended without an error condition and I see the table I specified populated with both tables and data but it seems Iā€™m still using H2. I tried following all the steps in the migration page but did I miss something?

Hi @Greg
It would be very helpful if you posted the command youā€™re using to start Metabase after you have migrated, since Iā€™m guessing youā€™re not setting the environment variables.
https://www.metabase.com/docs/latest/operations-guide/configuring-application-database.html#mysql-or-mariadb
I would recommend setting up a service:
https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-debian

Thanks for the reply.

I do have environment variables set (Iā€™m not sure how the migration would have been possible without them?):

MB_DB_DBNAME="meta"
MB_DB_HOST="localhost"
MB_DB_PASS="password"
MB_DB_PORT="3306"
MB_DB_TYPE="mysql"
MB_DB_USER="metabase"

I also have Metabase already setup as a service. (I had to remind myself of that when it would re-spawn every time I would kill the process and it would automatically restart.)

Looking at the Debian page you linked to, do I need the MB_DB_TYPE environment variable? Iā€™m also confused by ā€œpost the command youā€™re using to start Metabaseā€ - in every place I see, itā€™s just java -jar /path/to/metabase.jar.

@Greg Correct, you need to define MB_DB_TYPE=mysql in your service script, otherwise it doesnā€™t know that it should be using MySQL instead of H2.
If you have setup a SystemD service with EnvironmentFile, then those envvars are parsed down the ExecStart, so that should be enough.
I guess the problem was that you just didnā€™t have MB_DB_TYPE defined.

Got it. I actually had put the environment variables in my own userā€™s profile instead of the /etc/default/metabase file. Fixed that, rebooted and weā€™re on MySQL!

Thanks, @flamber.

1 Like