Unable to run config migrate

Summary

Running the config migrate command is always failing

Steps to reproduce

With mattermost 5.21.0, on CentOS 7, try:

bin/mattermost config migrate /path/to/config.json "user:pass@tcp(server:port)/mattermost?sslmode=disable&connect_timeout=10"

or

bin/mattermost config migrate /path/to/config.json "mysql://user:pass@server:port/mattermost?sslmode=disable&connect_timeout=10"

Expected behavior

Config migrate runs

Observed behavior

With connect string formatted as in config:

$ bin/mattermost config migrate ~/mattermost-installdir/config/config.json "${MM_SQLSETTINGS_DATASOURCE}"
{"level":"warn","msg":"DefaultServerLocale must be one of the supported locales. Setting DefaultServerLocale to en as default value."}
{"level":"warn","msg":"DefaultClientLocale must be one of the supported locales. Setting DefaultClientLocale to en as default value."}
{"level":"warn","msg":"DefaultServerLocale must be one of the supported locales. Setting DefaultServerLocale to en as default value."}
{"level":"warn","msg":"DefaultClientLocale must be one of the supported locales. Setting DefaultClientLocale to en as default value."}
Error: failed to migrate config: failed to access destination config <user>:<pass>@tcp(<server>:<port>)/mattermost?charset=utf8mb4: failed to load: failed to persist required changes after load: failed to write file: open /home/mattermost/mattermost-installdir/mattermost/config/<user>:<pass>@tcp(<server>:<port>)/mattermost?charset=utf8mb4: no such file or directory
Usage:
$ bin/mattermost config  migrate ~/mattermost-installdir/config/config.json "${MATTERMOST_MYSQL_URL}&sslmode=disable&connect_timeout=10"
{"level":"warn","msg":"DefaultServerLocale must be one of the supported locales. Setting DefaultServerLocale to en as default value."}
{"level":"warn","msg":"DefaultClientLocale must be one of the supported locales. Setting DefaultClientLocale to en as default value."}
Error: failed to migrate config: failed to access destination config mysql://<user>:<pass>@<server>:<port>/mattermost?charset=utf8mb4&sslmode=disable&connect_timeout=10: failed to initialize: failed to create Configurations table: default addr for network '<server>:<port>' unknown
Usage:
 ...

I confirmed that from this shell I can telnet to the destination server and port.

I also tried:

  1. Passing my current config to this command with the --config flag (no change)
  2. Using the IP of the destination server instead of the DNS name (no change)

What OS and version are you on?

@paulrothrock Would support team be familiar with this issue?

@gubbins, the connection string needs to match the DataSource configuration format as used in config.json. For MySQL, here’s an example string: mmuser:mostest@tcp(localhost:3306)/mattermost_test?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s

@amy.blais CentOS 7 (edited original post to include this)

Sorry I did say in the original post that I tried the connect string as well, but it seems to treat it as a filename and says no such file or directory. I have now edited my original post to illustrate that more clearly.

Thanks, @gubbins – I think you have bits of both, but the format required for the migrate CLI looks like:

mysql://<user>:<pass>@tcp(<server>:<port>/mattermost?charset=utf8mb4

That is, it looks like mysql://${MM_SQLSETTINGS_DATASOURCE}.

Thankyou - that did not occur to me to try for some reason! It worked.