# \[Solved\] Upgrading to version 9.10.1-0 fails on database migration

**URL:** <https://forum.mattermost.com/t/solved-upgrading-to-version-9-10-1-0-fails-on-database-migration/19170>\
**Category:** Troubleshooting\
**Created:** [August 1, 2024, 2:58pm UTC](https://forum.mattermost.com/t/solved-upgrading-to-version-9-10-1-0-fails-on-database-migration/19170 "2024-08-01T14:58:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfn](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dfn](https://forum.mattermost.com/u/dfn)\
**Post date:** [August 1, 2024, 2:58pm UTC](https://forum.mattermost.com/t/solved-upgrading-to-version-9-10-1-0-fails-on-database-migration/19170/1 "2024-08-01T14:58:40Z")

</div>

**Summary**  
After upgrading mattermost (self hosted), the service start fails on database migration with an error message.

**Steps to reproduce**  
Using apt-get (using mattermost server repo) to upgrade to version 9.10.1-0 from the next to last version.  
Mattermost was installed following “[Install Mattermost Server on Ubuntu - Mattermost documentation](https://docs.mattermost.com/install/install-ubuntu.html#install)”

MariaDB is on version: 10.3.39  
System is Ubuntu 20.04 LTS.

**Expected behavior**  
Expected restart after upgrading mattermost via apt-get.

**Observed behavior**  
After upgrading mattermost (self hosted) to version 9.10.1-0 from the next to last version, mattermost service fails on database migration with an error message (taken from mattermost.log):

error [2024-08-01 16:17:00.164 +02:00] failed to initialize platform: cannot create store: failed to apply database migrations: driver: mysql, message: failed when applying migration, command: apply\_migration, originalError: Error 1044 (42000): Access denied for user ‘mmuser’@‘localhost’ to database ‘mattermost’, query:

```auto
CREATE PROCEDURE RemoveUuploadFilePermission()
BEGIN
    updateRoles: LOOP
        -- update affected rows
        UPDATE Roles
            SET Permissions = REGEXP_REPLACE(Permissions, 'upload_file([[:space:]]|$)', '')
            WHERE Permissions like '%upload_file%' and Permissions not REGEXP 'create_post([[:space:]]|$)'
            LIMIT 100;

          -- check if the loop has completed
          IF ROW_COUNT() < 100 THEN
              LEAVE updateRoles;
          END IF;
    END LOOP updateRoles;
END;

CALL RemoveUuploadFilePermission();
DROP PROCEDURE IF EXISTS RemoveUuploadFilePermission;

 caller="commands/server.go:76"

```

[End of log excerpt]

The mattermost instance was running stable before. User ‘mmuser’ does have privileges on database ‘mattermost’ - which I had re-checked on the mysql prompt. The error message may be misleading then. Does anyone have an idea what has happened and what may fix it?

---

<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:** [August 10, 2024, 1:01am UTC](https://forum.mattermost.com/t/solved-upgrading-to-version-9-10-1-0-fails-on-database-migration/19170/2 "2024-08-10T01:01:11Z")

</div>

Hi dfn! Thank you for reaching out and providing detailed information! It sounds like you may be encountering an issue with database permissions during the migration. You might want to double-check the `mmuser` permissions on the Mattermost database. Additionally, reviewing the [Mattermost upgrade guide](https://docs.mattermost.com/upgrade/upgrading-mattermost-server.html) and the [database setup documentation](https://docs.mattermost.com/install/prepare-mattermost-database.html) could provide more insights. Please let us know if the issue persists, and we’ll assist further!

---

<div class="post-metadata">

**Author:** ![dfn](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dfn](https://forum.mattermost.com/u/dfn)\
**Post date:** [October 8, 2024, 11:04am UTC](https://forum.mattermost.com/t/solved-upgrading-to-version-9-10-1-0-fails-on-database-migration/19170/3 "2024-10-08T11:04:03Z")

</div>

For anyone stumbling upon, the issue has been solved by migrating the database system to PostgreSQL and re-installing Mattermost.

---

<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:** [October 8, 2024, 7:03pm UTC](https://forum.mattermost.com/t/solved-upgrading-to-version-9-10-1-0-fails-on-database-migration/19170/4 "2024-10-08T19:03:40Z")

</div>

Woot! Thank you for following up with the solution, dfn!
