[Solved] Migration from mysql to postgres

DB Connection after migration from mysql to postgres.

Following error messages whenattempting to start service

root@mattermost-test:/opt/mattermost/config# systemctl status mattermost.service
● mattermost.service - Mattermost
Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
Active: activating (start) since Thu 2024-11-07 16:21:18 EST; 7s ago
Main PID: 29235 (mattermost)
Tasks: 8 (limit: 9394)
Memory: 44.8M
CPU: 325ms
CGroup: /system.slice/mattermost.service
└─29235 /opt/mattermost/bin/mattermost

Nov 07 16:21:18 mattermost-test systemd[1]: Starting Mattermost…
Nov 07 16:21:18 mattermost-test mattermost[29235]: {“timestamp”:“2024-11-07 16:21:18.747 -05:00”,“level”:“info”,“msg”:“Server is initializing…”,“caller”:“platform/service.go:175”,“go_version”:“go1.21.8”}
Nov 07 16:21:18 mattermost-test mattermost[29235]: {“timestamp”:“2024-11-07 16:21:18.748 -05:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sql/sql_utils.go:67”,“database”:“master”,“dataSource”:“mmuser:MatterMostPassword1@localhost/mattermost?connect_timeout=10&sslmode=disabled”}
Nov 07 16:21:18 mattermost-test mattermost[29235]: {“timestamp”:“2024-11-07 16:21:18.754 -05:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sql/sql_utils.go:75”,“database”:“master”,“dataSource”:“mmuser:MatterMostPassword1@localhost/mattermost?connect_timeout=10&sslmode=disabled”,"retryin>

Hi @itGirl27! It sounds like you might be encountering a connection issue with the new Postgres setup. I’d recommend double-checking your database configuration in config.json, especially to ensure your connection string details match your Postgres setup. You might also find our MySQL to PostgreSQL documentation helpful in verifying the settings. Let us know how it goes!

This is not the full error message. Please show us the full message.

Use a CLI tool like psql to connect to the DB from the MM server and verify that connectivity and user/pass is correct.

Here is the full error message:

Nov 08 10:12:13 mattermost-test systemd[1]: Starting Mattermost...
Nov 08 10:12:13 mattermost-test mattermost[35899]: {"timestamp":"2024-11-08 10:12:13.980 -05:00","level":"info","msg":"Server is initializing...","caller":"platform/service.go:175","go_version":"go1.21.8"}
Nov 08 10:12:13 mattermost-test mattermost[35899]: {"timestamp":"2024-11-08 10:12:13.981 -05:00","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:67","database":"master","dataSource":"mmuser:USERPAssword@tcp(127.0.0.1:5432)/mattermost?connect_timeout=10&sslmode=disabled"}
Nov 08 10:12:13 mattermost-test mattermost[35899]: {"timestamp":"2024-11-08 10:12:13.986 -05:00","level":"error","msg":"Failed to ping DB","caller":"sql/sql_utils.go:75","database":"master","dataSource":"mmuser:USERPAssword@tcp(127.0.0.1:5432)/mattermost?connect_timeout=10&sslmode=disable>

Would the steps listed here help this :

Currently, the configuration follows the syntax here

Did you check that port 5432 is open and accessible? Like this:

netstat -tulpen | grep 5432
# and
telnet localhost 5432

ncat is also possible instead of telnet, though.

I guess, the postgres service is running on the same machine as the mattermost service?
If not, you can’t use “localhost”. Use the hostname or IP of the postgres server instead.

1 Like

Just curious: the DataSource mentioned in the error message doesn’t contain “postgres://” - is this part of your config in config.json? Could you please post the corresponding lines of SqlSettings?

Thanks for your help. I was able to get it to start.

2 Likes

Good that you were able to resolve it. But this is still not the full error message. Notice that your last line is ending with =disable>. It should end with a } indicating end of the JSON log.

I think once you get the full error message, the fact that it’s trying with the incorrect driver should be clear.