Mattermost, Inc.

[Solved] Failed to ping db error

Hey there,

I’m setting up Mattermost on my current server without a docker container, and would like to use my existing MySQL install. I added a new user and a ‘mattermost’ database, and I can log in to the database from the command line with no issues.

I set DriverName to “mysql” and DataSource to “username:password@127.0.0.1:3306/mattermost?charset=utf8”.

When I run /opt/mattermost/bin/platform, I get this:

[10:54:05 EDT 2016/03/17] [INFO] (github.com/mattermost/platform/utils.GetTranslationsBySystemLocale:52) Loaded system translations for ‘en’ from ‘/opt/mattermost/i18n/en.json’
[2016/03/17 10:54:05 EDT] [INFO] Current version is 2.1.0 (2.1.0/Mon Mar 14 20:45:23 UTC 2016/f189bc2073cf800c5f4506a69bdb51d7065269bf)
[2016/03/17 10:54:05 EDT] [INFO] Enterprise Enabled: false
[2016/03/17 10:54:05 EDT] [INFO] Current working directory is /opt/mattermost/bin
[2016/03/17 10:54:05 EDT] [INFO] Loaded config file from /opt/mattermost/config/config.json
[2016/03/17 10:54:05 EDT] [INFO] Server is initializing…
[2016/03/17 10:54:05 EDT] [INFO] Pinging sql master database
[2016/03/17 10:54:05 EDT] [CRIT] Failed to ping db err:Default addr for network ‘127.0.0.1:3306’ unknown
panic: Failed to open sql connection Default addr for network ‘127.0.0.1:3306’ unknown

I’m not sure what I’m doing wrong, especially since I can connect to my mysql server through the command line client with no issues.

Any thoughts?

In case this helps anyone, I realized my issue.

My DataSource was set to “username:password@127.0.0.1:3306/mattermost” but it should have been “username:password@tcp(127.0.0.1:3306)/mattermost”.

3 Likes

That helps a lot! Thanks!

Good to see that as a reminder. This should be the default or there should be a comment to make things a bit more clear here.