Migrating from H2 to MySQL ends with H2

After reading several topics on this type of migration, I am getting lost. I am using metabase which originaly was running on H2. I followed Metabase' guidelines to migrate to MySQL and as far as I saw, it went well....except when I restart the server, I am still using H2 according to Diagnostic Info below. Any idea what I've missed ?

{
  "browser-info": {
    "language": "fr",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.11+9-Ubuntu-0ubuntu2.18.04",
    "java.vendor": "Ubuntu",
    "java.vendor.url": "https://ubuntu.com/",
    "java.version": "11.0.11",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.11+9-Ubuntu-0ubuntu2.18.04",
    "os.name": "Linux",
    "os.version": "4.15.0-163-generic",
    "user.language": "fr",
    "user.timezone": "Europe/Paris"
  },
  "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": "2021-12-02",
      "tag": "v0.41.3.1",
      "branch": "release-x.41.x",
      "hash": "20f9097"
    },
    "settings": {
      "report-timezone": "Europe/Paris"
    }
  }
}

Thanks for your advices,
Guillaume

Hi @GAuber
Environment variables are not preserved across sessions (like rebooting a server), so that's why it's not "remembering" your MySQL after reboot.
You will need to redefine them, or setup a service, which defines them when it starts:
https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-debian.html

Thanks for speedy feedback. Will look into this.

I managed to follow the procedure but ended up with Nginx Bad Gateway error (which I didn't have while running H2)... why switching DB causes Nginx error ? Any idea ? (I revert back to H2 and have no problem anymore)

@GAuber No, but you're doing some else too. Post the logs or exactly what you are doing.

@flamber, so what I did is the following:
0) Creating environment variables and executing: java -jar metabase.jar load-from-h2 /path/to/metabase.db
(It created the tables within the DB just fine)

  1. Adding the EnvironmentFile variable to metabase.service
  2. Creating "/etc/default/metabase" with the environment variables (except I didn't know what to put on MB_JETTY_HOST AND ..._PORT)
  3. I didn't touch nginx conf file since this was working fine with H2
  4. registering metabase-service
  5. Restarting Metabase
  6. Crying
  7. back to step 0)

I am not sure if log is properly configured too. Is there a different log from the one I can find in 'Troubleshooting' ?

@GAuber If you are migrating from H2 to MySQL, then you should not do that through a service.
It's a one-off process, which should be done completely separately from trying to run as a service.
The log in Admin > Troubleshooting > Logs should be the same as you see in the file log, if you've setup SystemD to log to a file.

So first do that:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html

Then when you are running on MySQL, then shutdown, configure your service environment variables to reference the MySQL and otherwise follow what is listed in the service guide:
https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-debian.html

Do not set host or port, the defaults are fine, when using Nginx as a reverse-proxy.