Can't install with external mysql database

I ran:

sudo docker run -d -p 3000:3000 --add-host metabase-db-host:
-e “MB_DB_TYPE=mysql”
-e “MB_DB_DBNAME=metabase”
-e “MB_DB_PORT=3306”
-e “MB_DB_USER=username”
-e “MB_DB_PASS=password”
-e “MB_DB_HOST=my-database-host”
–name metabase metabase/metabase

Which gives me this feedback:

Unable to find image ‘metabase/metabase:latest’ locally
latest: Pulling from metabase/metabase
e110a4a17941: Pull complete
5726fbb708f0: Pull complete
7c322de39b42: Pull complete
e00b172abb18: Pull complete
f53440e31a7d: Pull complete
6cc97e508d50: Pull complete
c1cedf9a9522: Pull complete
Digest: sha256:3683e8459458c6419ffc5300a9f04c41a5ca8a6d8c5ac0c086e0b534d2612fa3
Status: Downloaded newer image for metabase/metabase:latest
37b4333179c9f8161055d044f41d1b78ddff98c7edc8d80130b6426755911d4e

I viewed the logs with the following:

sudo docker logs metabase
06-25 04:18:47 INFO metabase.util :: Loading Metabase…
06-25 04:18:57 INFO util.encryption :: DB details encryption is DISABLED for this Metabase instance. :unlock:
06-25 04:19:07 INFO metabase.core :: Starting Metabase in STANDALONE mode
06-25 04:19:08 INFO metabase.core :: Launching Embedded Jetty Webserver with config:
{:port 3000, :host “37b4333179c9”}

06-25 04:19:08 INFO metabase.core :: Starting Metabase version v0.24.2 (b859d40 release-0.24.2) …
06-25 04:19:08 INFO metabase.core :: System timezone is ‘GMT’ …
06-25 04:19:08 DEBUG metabase.driver :: Registered driver :bigquery :truck:
06-25 04:19:08 DEBUG metabase.driver :: Registered driver :crate :truck:
06-25 04:19:08 DEBUG metabase.driver :: Registered driver :druid :truck:
06-25 04:19:08 DEBUG metabase.driver :: Registered driver :googleanalytics :truck:
06-25 04:19:08 DEBUG metabase.driver :: Registered driver :h2 :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :mongo :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :mysql :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :postgres :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :presto :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :redshift :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :sqlite :truck:
06-25 04:19:09 DEBUG metabase.driver :: Registered driver :sqlserver :truck:
06-25 04:19:09 INFO metabase.core :: Setting up and migrating Metabase DB. Please sit tight, this may take a minute…
06-25 04:19:09 INFO metabase.db :: Verifying mysql Database Connection …
06-25 04:19:09 ERROR metabase.driver :: Failed to connect to database: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
java.lang.AssertionError: Assert failed: Unable to connect to Metabase mysql DB.
(binding [allow-potentailly-unsafe-connections true] (require (quote metabase.driver)) ((resolve (quote metabase.driver/can-connect-with-details?)) engine details))
at metabase.db$verify_db_connection.invokeStatic(db.clj:334)
at metabase.db$verify_db_connection.invoke(db.clj:327)
at metabase.db$verify_db_connection.invokeStatic(db.clj:330)
at metabase.db$verify_db_connection.invoke(db.clj:327)
at metabase.db$setup_db_BANG_.invokeStatic(db.clj:382)
at metabase.db$setup_db_BANG_.doInvoke(db.clj:376)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at metabase.core$init_BANG_.invokeStatic(core.clj:103)
at metabase.core$init_BANG_.invoke(core.clj:82)
at metabase.core$start_normally.invokeStatic(core.clj:187)
at metabase.core$start_normally.invoke(core.clj:181)
at metabase.core$_main.invokeStatic(core.clj:279)
at metabase.core$_main.doInvoke(core.clj:274)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at metabase.core.main(Unknown Source)
06-25 04:19:09 ERROR metabase.core :: Metabase Initialization FAILED: Assert failed: Unable to connect to Metabase mysql DB.
(binding [allow-potentailly-unsafe-connections true] (require (quote metabase.driver)) ((resolve (quote metabase.driver/can-connect-with-details?)) engine details))
06-25 04:19:09 INFO metabase.core :: Metabase Shutting Down …
06-25 04:19:09 INFO metabase.core :: Metabase Shutdown COMPLETE

I verified the login credentials:

mysql -u username -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

I restored to my earlier image (base server with mysql and docker installed but no containers) but this time I install docker with the base default:

sudo docker run -d -p 3000:3000 --name metabase metabase/metabase
[sudo] password for username:
Unable to find image ‘metabase/metabase:latest’ locally
latest: Pulling from metabase/metabase
e110a4a17941: Pull complete
5726fbb708f0: Pull complete
7c322de39b42: Pull complete
e00b172abb18: Pull complete
f53440e31a7d: Pull complete
6cc97e508d50: Pull complete
c1cedf9a9522: Pull complete
Digest: sha256:3683e8459458c6419ffc5300a9f04c41a5ca8a6d8c5ac0c086e0b534d2612fa3
Status: Downloaded newer image for metabase/metabase:latest
1b7f74a76e6e896fa27e8cf1d756a6630cec24b51159a13064d7e89de69cd34a

This time when I check the logs, everything installs correctly

sudo docker logs metabase
06-25 04:44:41 INFO metabase.util :: Loading Metabase…
06-25 04:44:52 INFO util.encryption :: DB details encryption is DISABLED for this Metabase instance. :unlock:
06-25 04:45:02 INFO metabase.core :: Starting Metabase in STANDALONE mode
06-25 04:45:02 INFO metabase.core :: Launching Embedded Jetty Webserver with config:
{:port 3000, :host “1b7f74a76e6e”}

06-25 04:45:02 INFO metabase.core :: Starting Metabase version v0.24.2 (b859d40 release-0.24.2) …
06-25 04:45:02 INFO metabase.core :: System timezone is ‘GMT’ …
06-25 04:45:02 DEBUG metabase.driver :: Registered driver :bigquery :truck:
06-25 04:45:02 DEBUG metabase.driver :: Registered driver :crate :truck:
06-25 04:45:02 DEBUG metabase.driver :: Registered driver :druid :truck:
06-25 04:45:02 DEBUG metabase.driver :: Registered driver :googleanalytics :truck:
06-25 04:45:02 DEBUG metabase.driver :: Registered driver :h2 :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :mongo :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :mysql :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :postgres :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :presto :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :redshift :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :sqlite :truck:
06-25 04:45:03 DEBUG metabase.driver :: Registered driver :sqlserver :truck:
06-25 04:45:03 INFO metabase.core :: Setting up and migrating Metabase DB. Please sit tight, this may take a minute…
06-25 04:45:03 INFO metabase.db :: Verifying h2 Database Connection …
06-25 04:45:04 INFO metabase.db :: Verify Database Connection … :white_check_mark:
06-25 04:45:04 INFO metabase.db :: Running Database Migrations…
06-25 04:45:04 INFO metabase.db :: Setting up Liquibase…
06-25 04:45:05 INFO metabase.db :: Liquibase is ready.
06-25 04:45:05 INFO metabase.db :: Checking if Database has unrun migrations…
06-25 04:45:09 INFO metabase.db :: Database has unrun migrations. Waiting for migration lock to be cleared…
06-25 04:45:09 INFO metabase.db :: Migration lock is cleared. Running migrations…
06-25 04:46:12 INFO metabase.db :: Database Migrations Current … :white_check_mark:
com.mchange.v2.cfg.DelayedLogItem [ level -> FINE, text -> “The configuration file for resource identifier ‘hocon:/reference,/application,/c3p0,/’ could not be found. Skipping.”, exception -> null]
06-25 04:46:12 INFO db.migrations :: Running all necessary data migrations, this may take a minute.
06-25 04:46:14 INFO db.migrations :: Running data migration ‘set-card-database-and-table-ids’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘set-mongodb-databases-ssl-false’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘set-default-schemas’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘set-admin-email’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘remove-database-sync-activity-entries’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘update-dashboards-to-new-grid’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘migrate-field-visibility-type’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘create-raw-tables’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘add-users-to-default-permissions-groups’…
06-25 04:46:14 INFO models.permissions-group :: Created magic permissions group ‘All Users’ (ID = 1)
06-25 04:46:14 INFO models.permissions-group :: Created magic permissions group ‘Administrators’ (ID = 2)
06-25 04:46:14 INFO db.migrations :: Running data migration ‘add-admin-group-root-entry’…
06-25 04:46:14 DEBUG models.permissions :: Granting permissions for group 2: /
06-25 04:46:14 INFO db.migrations :: Running data migration ‘add-databases-to-magic-permissions-groups’…
06-25 04:46:14 INFO models.permissions-group :: Created magic permissions group ‘MetaBot’ (ID = 3)
06-25 04:46:14 INFO db.migrations :: Running data migration ‘migrate-field-types’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘fix-invalid-field-types’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘copy-site-url-setting-and-remove-trailing-slashes’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘migrate-query-executions’…
06-25 04:46:14 INFO db.migrations :: Running data migration ‘drop-old-query-execution-table’…
06-25 04:46:14 INFO db.migrations :: Finished running data migrations.
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.activity-feed :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.dependencies :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.driver-notifications :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.last-login :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.metabot-lifecycle :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.notifications :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.revision :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.sync-database :ear:
06-25 04:46:14 INFO metabase.events :: Starting events listener: metabase.events.view-log :ear:
06-25 04:46:14 INFO metabase.task :: Loading tasks namespace: metabase.task.follow-up-emails :calendar:
06-25 04:46:14 INFO metabase.task :: Loading tasks namespace: metabase.task.send-anonymous-stats :calendar:
06-25 04:46:14 INFO metabase.task :: Loading tasks namespace: metabase.task.send-pulses :calendar:
06-25 04:46:14 INFO metabase.task :: Loading tasks namespace: metabase.task.sync-databases :calendar:
06-25 04:46:14 INFO metabase.task :: Loading tasks namespace: metabase.task.upgrade-checks :calendar:
06-25 04:46:14 INFO metabase.core :: Looks like this is a new installation … preparing setup wizard
06-25 04:46:14 INFO metabase.core :: Please use the following url to setup your Metabase installation:

http://1b7f74a76e6e:3000/setup/

06-25 04:46:14 INFO metabase.sample-data :: Loading sample dataset…
06-25 04:46:14 DEBUG models.permissions :: Granting permissions for group 1: /db/1/
06-25 04:46:14 DEBUG models.permissions :: Granting permissions for group 1: /db/1/
06-25 04:46:14 DEBUG models.permissions :: Granting permissions for group 3: /db/1/
06-25 04:46:14 DEBUG models.permissions :: Granting permissions for group 3: /db/1/
06-25 04:46:14 INFO metabase.sync-database :: Syncing H2 database ‘Sample Dataset’…
06-25 04:46:14 INFO sync-database.introspect :: Introspecting schema on H2 database ‘Sample Dataset’ …
06-25 04:46:14 DEBUG driver.generic-sql :: Creating new connection pool for database 1 …
06-25 04:46:15 DEBUG sync-database.introspect :: Found new table: PUBLIC.PRODUCTS
06-25 04:46:15 INFO sync-database.introspect :: [········································] :disappointed: 20% Synced table ‘PUBLIC.PRODUCTS’.
06-25 04:46:15 DEBUG sync-database.introspect :: Found new table: PUBLIC.ORDERS
06-25 04:46:15 INFO sync-database.introspect :: [······························] :neutral_face: 40% Synced table ‘PUBLIC.ORDERS’.
06-25 04:46:15 DEBUG sync-database.introspect :: Found new table: PUBLIC.PEOPLE
06-25 04:46:15 INFO sync-database.introspect :: [
····················] :relieved: 60% Synced table ‘PUBLIC.PEOPLE’.
06-25 04:46:15 DEBUG sync-database.introspect :: Found new table: PUBLIC._METABASE_METADATA
06-25 04:46:15 INFO sync-database.introspect :: [··········] :blush: 80% Synced table ‘PUBLIC._METABASE_METADATA’.
06-25 04:46:15 DEBUG sync-database.introspect :: Found new table: PUBLIC.REVIEWS
06-25 04:46:15 INFO sync-database.introspect :: [**************************************] :sunglasses: 100% Synced table ‘PUBLIC.REVIEWS’.
06-25 04:46:15 DEBUG sync-database.introspect :: Marking foreign key ‘PUBLIC.ORDERS.USER_ID’ -> ‘PUBLIC.PEOPLE.ID’.
06-25 04:46:15 DEBUG sync-database.introspect :: Marking foreign key ‘PUBLIC.ORDERS.PRODUCT_ID’ -> ‘PUBLIC.PRODUCTS.ID’.
06-25 04:46:15 DEBUG sync-database.introspect :: Marking foreign key ‘PUBLIC.REVIEWS.PRODUCT_ID’ -> ‘PUBLIC.PRODUCTS.ID’.
06-25 04:46:15 INFO sync-database.introspect :: Introspection completed on H2 database ‘Sample Dataset’ (580 ms)
06-25 04:46:15 INFO sync-database.analyze :: Analyzing data in H2 database ‘Sample Dataset’ (this may take a while) …
06-25 04:46:15 INFO middleware.cache :: Using query processor cache backend: :db :floppy_disk:
06-25 04:46:17 INFO sync-database.analyze :: [
······································] :unamused: 25% Analyzed table ‘ORDERS’.
06-25 04:46:18 DEBUG sync-database.analyze :: Field ‘PUBLIC.PEOPLE.EMAIL’ looks like it contains valid email addresses. Setting special_type to :type/Email.
06-25 04:46:18 INFO sync-database.analyze :: [
·························] :grimacing: 50% Analyzed table ‘PEOPLE’.
06-25 04:46:18 INFO sync-database.analyze :: [
**********************·············] :yum: 75% Analyzed table ‘PRODUCTS’.
06-25 04:46:19 DEBUG sync-database.analyze :: Field ‘PUBLIC.REVIEWS.BODY’ has an average length of 180. Not displaying it in previews.
06-25 04:46:19 INFO sync-database.analyze :: [**************************************************] :sunglasses: 100% Analyzed table ‘REVIEWS’.
06-25 04:46:19 INFO sync-database.analyze :: Analysis of H2 database ‘Sample Dataset’ completed (4 s).
06-25 04:46:19 INFO metabase.sync-database :: Finished syncing H2 database ‘Sample Dataset’. (5 s)
06-25 04:46:19 INFO metabase.core :: Metabase Initialization COMPLETE

The website loads right up. This leads me to believe that my problem has to do with the database setup and definitely not a system problem. I looked at the metabase site, and everything looks like the settings are correct. I am stumped.

I’m definitely not an expert on this, but it seems like there’s a problem with the initial command you used to run the Metabase Docker container…

First of all, it looks like you’re using --add-host to make a named reference to to some server; maybe you redacted the actual value, but the argument needs host-name:ip-address, not just host-name: (and that ip-address needs to be accessible from the Metabase container).

If you have the --add-host parameter correct, the next possible issue is with -e "MB_DB_HOST=my-database-host"; my-database-host should be the same as the host you specified with --add-host.

Overall, it seems like the container you’re running simply can’t reach the MySQL database server you’re specifying… is that enough to help?

New issue related to install using external MySQL DB.
New install.

metabase v0.24.2
DB = MySQL 5.7

ERROR
{:message
“You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘NULL) AND (visibility_type not in (‘sensitive’, ‘retired’)))’ at line 1”,
:stacktrace
[“api.database$fn__29843$fn__29844.invoke(database.clj:148)”
“api.common.internal$do_with_caught_api_exceptions.invokeStatic(internal.clj:229)”
“api.common.internal$do_with_caught_api_exceptions.invoke(internal.clj:224)”
“api.database$fn__29843.invokeStatic(database.clj:144)”
“api.database$fn__29843.invoke(database.clj:144)”
“middleware$enforce_authentication$fn__38784.invoke(middleware.clj:120)”
“api.routes$fn__38908.invokeStatic(routes.clj:58)”
“api.routes$fn__38908.invoke(routes.clj:58)”
“routes$fn__39540$fn__39541.doInvoke(routes.clj:64)”
“routes$fn__39540.invokeStatic(routes.clj:60)”
“routes$fn__39540.invoke(routes.clj:60)”
“middleware$log_api_call$fn__38883$fn__38885.invoke(middleware.clj:329)”
“middleware$log_api_call$fn__38883.invoke(middleware.clj:328)”
“middleware$add_security_headers$fn__38833.invoke(middleware.clj:243)”
“middleware$bind_current_user$fn__38788.invoke(middleware.clj:140)”
“middleware$maybe_set_site_url$fn__38837.invoke(middleware.clj:266)”],
:sql-exception-chain
[“MySQLSyntaxErrorException:”
“Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘NULL) AND (visibility_type not in (‘sensitive’, ‘retired’)))’ at line 1”
“SQLState: 42000”
“Error Code: 1064”]}