If you decide to use the default application database (H2) when you initially start using Metabase, but later decide that you’d like to switch to a more production-ready database such as MySQL or Postgres, we make the transition easy for you.
Metabase provides a custom migration command for upgrading H2 application database files by copying their data to a new database. Here’s what you’ll want to do:
export MB_DB_TYPE=postgres
export MB_DB_DBNAME=metabase
export MB_DB_PORT=5432
export MB_DB_USER=<username>
export MB_DB_PASS=<password>
export MB_DB_HOST=localhost
java -jar metabase.jar load-from-h2 /path/to/metabase.db # do not include .mv.db or .h2.db suffix
It is expected that you will run the command against a brand-new (empty!) database; Metabase will handle all of the work of creating the database schema and migrating the data for you.
utf8mb4_unicode_ci
collation, utf8mb4
character set, and innodb_large_prefix=ON
..h2.db
or .mv.db
extension to the database path you specify, so make sure the path to the DB file you pass to the command does not include it. For example, if you have a file named /path/to/metabase.db.h2.db
, call the command with load-from-h2 /path/to/metabase.db
.