3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

metabaseのデータ保存先をh2からmysqlに変更

3
Last updated at Posted at 2021-06-10

version v0.39.3

公式の https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-docker.html#using-postgres-as-the-metabase-application-databasehttps://www.metabase.com/docs/latest/operations-guide/configuring-application-database.html#mysql-or-mariadb に書いてあるとおり環境変数で制御する。

例えばjdbc-urlで指定する場合は以下のとおり。

MB_DB_CONNECTION_URI: mysql://db:3306/metabase?user=dbuser&password=userpass&allowPublicKeyRetrieval=true

接続先のmysqlにmetabase用のdatabaseが必要。以下のSQLは公式ガイドからコピペしたもの。

CREATE DATABASE metabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

mysqlも一緒に起動するとしてそこに接続する場合のdocker-compose.ymlの例は下記の通り。

docker-compose.yml
version: "3.7"

services:
  db:
    image: mysql
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_USER: dbuser
      MYSQL_PASSWORD: userpass
      MYSQL_DATABASE: metabase
    networks:
      - metabase-net

  metabase:
    image: metabase/metabase:latest
    ports:
      - "3000:3000"
    volumes:
      - ./plugins:/plugins
    environment:
      MB_DB_TYPE: mysql
      MB_DB_CONNECTION_URI: mysql://db:3306/metabase?user=dbuser&password=userpass&allowPublicKeyRetrieval=true
    networks:
      - metabase-net

networks:
  metabase-net:

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?