# \[Solved\] Migration from mysql to postgres

**URL:** <https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224>\
**Category:** Troubleshooting\
**Created:** [November 7, 2024, 9:22pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224 "2024-11-07T21:22:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![itGirl27](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@itGirl27](https://forum.mattermost.com/u/itGirl27)\
**Post date:** [November 7, 2024, 9:22pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/1 "2024-11-07T21:22:11Z")

</div>

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\>

---

<div class="post-metadata">

**Author:** ![john.combs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/john.combs/32/7118_2.png) [@john.combs](https://forum.mattermost.com/u/john.combs)\
**Post date:** [November 7, 2024, 11:30pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/2 "2024-11-07T23:30:24Z")

</div>

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](https://docs.mattermost.com/deploy/postgres-migration.html) helpful in verifying the settings. Let us know how it goes!

---

<div class="post-metadata">

**Author:** ![agnivade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agnivade/32/3846_2.png) [@agnivade](https://forum.mattermost.com/u/agnivade)\
**Post date:** [November 8, 2024, 8:34am UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/3 "2024-11-08T08:34:27Z")

</div>

> [@itGirl27](#):
>
> 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\>

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.

---

<div class="post-metadata">

**Author:** ![itGirl27](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@itGirl27](https://forum.mattermost.com/u/itGirl27)\
**Post date:** [November 8, 2024, 3:13pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/4 "2024-11-08T15:13:40Z")

</div>

Here is the full error message:

```auto
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>

```

---

<div class="post-metadata">

**Author:** ![itGirl27](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@itGirl27](https://forum.mattermost.com/u/itGirl27)\
**Post date:** [November 8, 2024, 3:14pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/5 "2024-11-08T15:14:41Z")

</div>

Would the steps listed here help this :

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/9/97207d586d7a3f6974dba5ffebe7c974665e1b53.png)

---

<div class="post-metadata">

**Author:** ![itGirl27](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@itGirl27](https://forum.mattermost.com/u/itGirl27)\
**Post date:** [November 8, 2024, 3:23pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/6 "2024-11-08T15:23:35Z")

</div>

Currently, the configuration follows the syntax here

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/1/11adc59ac251607af3bd4f89a0f7d39a1b2d8af9.png)

---

<div class="post-metadata">

**Author:** ![rtfm98](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@rtfm98](https://forum.mattermost.com/u/rtfm98)\
**Post date:** [November 8, 2024, 6:02pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/7 "2024-11-08T18:02:33Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![rtfm98](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@rtfm98](https://forum.mattermost.com/u/rtfm98)\
**Post date:** [November 8, 2024, 6:06pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/8 "2024-11-08T18:06:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![itGirl27](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@itGirl27](https://forum.mattermost.com/u/itGirl27)\
**Post date:** [November 8, 2024, 7:36pm UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/9 "2024-11-08T19:36:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![agnivade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agnivade/32/3846_2.png) [@agnivade](https://forum.mattermost.com/u/agnivade)\
**Post date:** [November 11, 2024, 8:39am UTC](https://forum.mattermost.com/t/solved-migration-from-mysql-to-postgres/21224/10 "2024-11-11T08:39:20Z")

</div>

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.
