Search code examples
mysqlmetabase

Metabase is not working (starting) with MySQL


I read the documentation about running metabase with docker from here and setting metabase up with mysql from here and followed all the instruction as per the documentation.

Here is the docker-compose.yml file I used to run metabase:

# docker-compose.yml
version: '3'
services:
  metabase:
    image: metabase/metabase:v0.39.1
    environment:
      - MB_DB_TYPE=mysql
      - MB_DB_DBNAME=metabase
      - MB_DB_PORT=3306
      - MB_DB_USER=secretuser
      - MB_DB_PASS=secretword
      - MB_DB_HOST=secrethost
    ports:
      - 3000:3000

When I run docker-compose up I get the following error.

metabase_1  | 2021-05-17 08:27:59,084 ERROR metabase.core :: Metabase Initialization FAILED
metabase_1  | liquibase.exception.MigrationFailedException: Migration failed for change set migrations/000_migrations.yaml::1::agilliland:
metabase_1  |      Reason: liquibase.exception.DatabaseException: (conn=32027) Table 'core_organization' already exists [Failed SQL: CREATE TABLE `metabase`.`core_organization` (`id` INT AUTO_INCREMENT NOT NULL, `slug` VARCHAR(254) NOT NULL, `name` VARCHAR(254) NOT NULL, `description` TEXT NULL, `logo_url` VARCHAR(254) NULL, `inherits` BIT(1) NOT NULL, CONSTRAINT `PK_CORE_ORGANIZATION` PRIMARY KEY (`id`), UNIQUE (`slug`)) ENGINE InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci]
metabase_1  |   at liquibase.changelog.ChangeSet.execute(ChangeSet.java:637)
..
..
metabase_1  | Caused by: java.sql.SQLException: Table 'core_organization' already exists
metabase_1  |   at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1688)
metabase_1  |   at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1550)
metabase_1  |   at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1513)
metabase_1  |   at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:256)
metabase_1  |   ... 57 more
metabase_1  | 2021-05-17 08:27:59,109 INFO metabase.core :: Metabase Shutting Down ...

I also tried to run directly without using compose file using this command:

docker run -d -p 3000:3000 -e "MB_DB_TYPE=mysql" -e "MB_DB_DBNAME=metabase" \
-e "MB_DB_PORT=3306" -e "MB_DB_USER=secretuser" -e 'MB_DB_PASS=secretpass' \
-e "MB_DB_HOST=secrethost" --name metabase metabase/metabase:v0.39.1

I get the exactly same error as with the compose file.

On further searches I found a similar issue in github stating that "Table 'core_organization' already exists", however, they claim that it is already fixed but I'm still having the issue. In the issue page they suggest: java -jar metabase.jar migrate force. How can I run this from docker ?

NOTE: I have tried to drop all the table and start with fresh schema multiple times and it didn't work as well.

NOTE: the database I use is AWS RDS, just to make sure that it's not related with AWS.


Solution

  • The root of the problem was that I didn't have permissions to ALTER and REFERENCE in AWS RDS. Once I got those permissions everything worked fine.