Setting up Mattermost for the first time on Unraid, unable to connect to mysql

Setting up Mattermost for the first time on Unraid, unable to connect to mysql

I’m using the official script built on the community apps.

I installed mysql, and when I input the information into data source like so:
MMUSER:Password@tcp(127.0.0.1:3306)/MM_DATABASE?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s

I get:
{“timestamp”:“2024-12-24 20:13:36.703 -05:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:270”,“database”:“master”,“dataSource”:“:@tcp(127.0.0.1:3306)/MM_DATABASE?charset=utf8mb4%2Cutf8%5Cu0026readTimeout%3D30s%5Cu0026writeTimeout%3D30s”,“retrying in seconds”:10,“error”:“dial tcp 127.0.0.1:3306: connect: connection refused”}

I also tried setting it to the IP and port that my server is running on, but then I get this error:

{“timestamp”:“2024-12-24 20:15:34.717 -05:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:270”,“database”:“master”,“dataSource”:“:@tcp(192.168.1.254:3306)/MM_DATABASE?charset=utf8mb4%2Cutf8%5Cu0026readTimeout%3D30s%5Cu0026writeTimeout%3D30s”,“retrying in seconds”:10,“error”:“Error 1045 (28000): Access denied for user ‘MMUSER’@‘172.17.0.1’ (using password: YES)”}

I tried swapping to postgres, but it seems the setup is also a bit different.

I’m just testing this for a nonprofit to see if it’ll work for what we need, so I’m willing to try many things to get this to work.

1 Like

Support for MySQL is being deprecated. Use PostgreSQL.

Your MySQL issues are probably A) an issue with the password (whenever this happens, I always suggest falling back to a very simple password, get it working, then make the password more complex); and B) you can allow the mysql user to connect on 127.0.0.1 but not localhost, or via hostname but not IP address.

1 Like

Hi John, I swapped the driver set to postgres, I’m running postgres17 on my server.

However, I am now getting this error:

{“timestamp”:“2024-12-25 10:08:10.264 -05:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:270”,“database”:“master”,“dataSource”:“mmuser:Password@tcp(127.0.0.1:5432)/MM_DATABASE?charset=utf8mb4%2Cutf8%5Cu0026readTimeout%3D30s%5Cu0026writeTimeout%3D30s”,“retrying in seconds”:10,“error”:“dial tcp 127.0.0.1:5432: connect: connection refused”}

are the variable names for Postgres different than mysql?

No, the DataSource would look the same.

Can you use psql to connect to your database? You need to make sure you’ve granted the appropriate permissions to your mattermost user, and that your pg_hba.conf allows TCP connections. Check every step in Prepare your Mattermost database - Mattermost documentation

I can use psql inside my psql container, which is separate from the mattermost container.

I followed the steps exactly on that page using Postgres17

And am still receiving the following error:

{“timestamp”:“2024-12-25 22:29:09.171 -05:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sqlstore/store.go:262”,“database”:“master”,“dataSource”:“mmuser:password@127.0.0.1:5432/mattermost?connect_timeout=10&sslmode=disable”}
{“timestamp”:“2024-12-25 22:29:09.172 -05:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:270”,“database”:“master”,“dataSource”:“mmuser:password@127.0.0.1:5432/mattermost?connect_timeout=10&sslmode=disable”,“retrying in seconds”:10,“error”:“dial tcp 127.0.0.1:5432: connect: connection refused”}

The postgres is listening on 0.0.0.0:5432
The config files have been adjusted as mentioned and I’m still unable to get this to work.

did you happen to figure this out… im trying to completely reinstall Mattermost using Postgres and I can’t seem to get it to work

No I haven’t.

Either there’s an issue with the script, UnRaid config, or there needs to be a specified Postgres version that needs to be used.

My guess is one of the first two, because in my situation, everything on the Postgres side is correct, I’m not sure if it needs to be installed into the same container, but I’m going to try that here in a bit.

well id really appreciate if you can let me know if you get it working and how you did it… ive had it working fine for over a year the old way with mysql but there is features that don’t work as im sure you are aware now.

If you cannot use psql from the Mattermost container, you’re networking is not right. 5432/TCP needs to be exposed on the postgres container to incoming connections.

1 Like

I got it all figured out now… thanks… @rustybeef if you need a hand let me know… I know how to setup and configure it with unraid docker using Postgres

1 Like

Feel free to share what worked for you, because I couldn’t get it to work no matter what I tried

1 Like

you need to use postgresql17 docker from the community apps,

when you install Mattermost from the community apps you need to change the Repository from mattermost/mattermost-team-edition:master to mattermost/mattermost-team-edition:latest

all the ports can stay default and your datasource should be like this postgres://yourusername:yourpassword@yourlocal_IP:5432/yourdatabaseusername?sslmode=disable&connect_timeout=10

(the username password and db name are what you set in postgresql17 docker)

App Host should be changed to your servers local IP

if you want to use the calls and screen share in mattermost you need to add Port for calls 8443 UDP

under more settings you need to change the MM_SQLSETTINGS_DRIVERNAME from mysql to Postgres

1 Like

did you get it to work now?