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