We're Hiring!

Mattermost, Inc.

MySQL Config showing access denied but not user in config

I’m having to set up a new server and our config file looks like this;

"DriverName": "mysql",
"DataSource": "mysql://custom_mmuser:Password@tcp(127.0.0.1:3306)/custom_mattermost_db?sslmode=disable\u0026connect_timeout=10",

I’m getting this error when we run the server;

Failed to ping DB","error":"Error 1045: Access denied for user 'mysql'@'localhost' (using password: YES)","retrying in seconds":10}

The odd thing is the username “mysql@localhost” does not match and nothing I do in the config file get mattermost to recognize the right username or IP.

It almost seems like it is not reading the right config file but everytime I run mattermost.exe it updates the config file and I have to reload the changes.

What am I doing wrong?

Hello, @GChester

The format of DataSource when you are using MySQL should look like this:

"DataSource": "custom_mmuser:Password@tcp(127.0.0.1:3306)/custom_mattermost_db?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s"

The one that you shared looks more like the PostgreSQL. Can you please make the necessary changes and let me know if it works properly on your end?

1 Like

@ahmaddanial is totally right. I have had the same issues because of Mattermost’s tutorial here: Configuration in the Mattermost Database — Mattermost 5.37 documentation

They say it should look like mysql:// but that’s only needed in the environment file (if you use it). Took me some time to figure this out. Thanks again @ahmaddanial !

1 Like

Hi, @crypt0jan

You are most welcome. Any time!