Mattermost Stops Working After Stopping MySQL Post-Migration to PostgreSQL

Problem

After migrating your Mattermost deployment from MySQL to PostgreSQL, you may encounter an issue where stopping the MySQL service causes the Mattermost application to shut down unexpectedly. This behavior persists even though the PostgreSQL migration appears successful and the application is configured to use PostgreSQL.


Cause

This issue is typically caused by the Mattermost systemd service configuration still referencing the MySQL service as a dependency. Specifically, the BindsTo and After directives in the systemd unit file are set to mysql.service. As a result, stopping MySQL also stops the Mattermost service.


Solution

To resolve the issue, you’ll need to update the systemd service file to reference postgresql.service instead of mysql.service.

  1. Locate the Mattermost systemd service file
    This is usually located at:

    /lib/systemd/system/mattermost.service
    

    or

    /etc/systemd/system/mattermost.service
    
  2. Open the file and review the contents.
    It may look something like this:

    [Unit]
    Description=Mattermost
    After=network.target
    After=mysql.service
    BindsTo=mysql.service
    
    [Service]
    Type=notify
    ExecStart=/opt/mattermost/bin/mattermost
    TimeoutStartSec=3600
    KillMode=mixed
    Restart=always
    RestartSec=10
    WorkingDirectory=/opt/mattermost
    User=mattermost
    Group=mattermost
    LimitNOFILE=49152
    
    [Install]
    WantedBy=mysql.service
    
  3. Update all instances of mysql.service to postgresql.service:

    [Unit]
    Description=Mattermost
    After=network.target
    After=postgresql.service
    BindsTo=postgresql.service
    
    [Service]
    Type=notify
    ExecStart=/opt/mattermost/bin/mattermost
    TimeoutStartSec=3600
    KillMode=mixed
    Restart=always
    RestartSec=10
    WorkingDirectory=/opt/mattermost
    User=mattermost
    Group=mattermost
    LimitNOFILE=49152
    
    [Install]
    WantedBy=multi-user.target
    

     

  4. After updating the service configuration, make sure to restart the Mattermost service to apply the changes.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.