# Upgrading from 5.25.0 Mattermost SQL Error Creating Database tables

**URL:** <https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316>\
**Category:** Troubleshooting\
**Created:** [March 1, 2021, 8:07pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316 "2021-03-01T20:07:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 1, 2021, 8:07pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/1 "2021-03-01T20:07:41Z")

</div>

For feature requests, please see:

For troubleshooting questions, please post in the following format:

#### Summary

I am trying to restore a backup from Bitnami Team Edition AWS Marketplace version EC2 to another instance. This does not seem to be working. I already have backup taken and uploaded to new instance. I am following Part B of this: [Create and restore application backups](https://docs.bitnami.com/general/apps/mattermost/administration/backup-restore/)  
This works and I am able to get the new instance working. But after this I want to upgrade from 5.25 like this: 5.25.0 → 5.25.7-\>v5.26.2 → v5.27.2 -\>v5.28.2 -\>v5.29.2 -\>v5.30.3 → v5.31.1 \*Extended Support Release (ESR)-\>v5.32.1 .

Firstly when I restore backup onto the new instance, I go back to version 5.25.0. After that I am upgrading using this guide: [Upgrade Mattermost Team Edition](https://docs.bitnami.com/general/apps/mattermost/administration/upgrade/)

After upgrading to 5.26 mattermost is not working. I see this error: {“level”:“info”,“ts”:1614628262.9054418,“caller”:“sqlstore/supplier.go:227”,“msg”:“Pinging SQL”,“database”:“master”}  
{“level”:“error”,“ts”:1614628262.9204803,“caller”:“sqlstore/supplier.go:174”,“msg”:“Error creating database tables.”,“error”:“Error 1146: Table ‘bitnami\_mattermost.sidebarcategories’ doesn’t exist”}

#### Steps to reproduce

How can we reproduce the issue (what version are you using?) Version 5.25.0 → 5.25.7-\>5.26.2

#### Expected behavior

Upgrade should work properly according to guide

#### Observed behavior

What did you see happen? Please include relevant error messages and/or screenshots.  
Mattermost starts when doing ctlscript.sh restart  
But then I see the error given above and I cannot open the url. It says 502 nginx error.

Please advise.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 2, 2021, 2:12am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/2 "2021-03-02T02:12:26Z")

</div>

Hello, @k0ushik

The error below indicates that there is an issue with the creating the `SidebarCategories` table on the database:

```auto
{“level”:“error”,“ts”:1614628262.9204803,“caller”:“sqlstore/supplier.go:174”,“msg”:“Error creating database tables.”,“error”:“Error 1146: Table ‘bitnami_mattermost.sidebarcategories’ doesn’t exist”}` 

```

```auto
mysql> DESCRIBE SidebarCategories;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| Id | varchar(26) | NO | PRI | NULL | |
| UserId | varchar(26) | YES | | NULL | |
| TeamId | varchar(26) | YES | | NULL | |
| SortOrder | bigint(20) | YES | | NULL | |
| Sorting | varchar(64) | YES | | NULL | |
| Type | varchar(64) | YES | | NULL | |
| DisplayName | varchar(64) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
7 rows in set (0.00 sec)

```

It could either mean that there is a permissions and ownership issue of MySQL data directory or corrupted / improper table name.

Can you please share the following output and remove the sensitive information such as password and IP address?

```auto
cat /opt/bitnami/apps/mattermost/server/config/config.json | grep -A12 "SqlSettings"

```

I would also like to check the ownership and permission of the database in use. Switch to root access and run `ls -lAh /var/lib/mysql | grep "<database_name>"`. In your case, I believe it should be `bitnami_mattermost` based on the error we are seeing.

For example, this is how it looks like on my side based on my database table `mattermost`:

```auto
root@mattermost:~# ls -lAh /var/lib/mysql | grep "mattermost"
drwxr-x--- 2 mysql mysql 12K Mar 2 01:51 mattermost

```

Lastly, run the mysqlcheck to verify the status of the tables. For example:

```auto
ahmaddanial@mattermost:~$ mysqlcheck -u <username> -p <database_name>
Enter password:
mattermost.Audits OK
mattermost.Bots OK
mattermost.ChannelMemberHistory OK
mattermost.ChannelMembers OK
mattermost.Channels OK
mattermost.ClusterDiscovery OK
mattermost.CommandWebhooks OK
mattermost.Commands OK
mattermost.Compliances OK
mattermost.Emoji OK
mattermost.FileInfo OK
mattermost.GroupChannels OK
mattermost.GroupMembers OK
mattermost.GroupTeams OK
mattermost.IncomingWebhooks OK
mattermost.Jobs OK
mattermost.Licenses OK
mattermost.LinkMetadata OK
mattermost.OAuthAccessData OK
mattermost.OAuthApps OK
mattermost.OAuthAuthData OK
mattermost.OutgoingWebhooks OK
mattermost.PluginKeyValueStore OK
mattermost.Posts OK
mattermost.Preferences OK
mattermost.PublicChannels OK
mattermost.Reactions OK
mattermost.Roles OK
mattermost.Schemes OK
mattermost.Sessions OK
mattermost.SidebarCategories OK
mattermost.SidebarChannels OK
mattermost.Status OK
mattermost.Systems OK
mattermost.TeamMembers OK
mattermost.Teams OK
mattermost.TermsOfService OK
mattermost.Tokens OK
mattermost.UserAccessTokens OK
mattermost.UserGroups OK
mattermost.UserTermsOfService OK
mattermost.Users OK

```

Keep me posted. Thanks.

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 2:40am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/3 "2021-03-02T02:40:21Z")

</div>

> [@ahmaddanial](#):
>
> `cat /opt/bitnami/apps/mattermost/server/config/config.json | grep -A12 "SqlSettings"`

 ![m1](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/f/f7d93658e63c236a785f4dae9d7e7c2054d494c1.png) ![m2](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/9/9032739addcf58e1ff3d1746a405366343277d8d.png)

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 2:49am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/4 "2021-03-02T02:49:07Z")

</div>

Just to be clear: These outputs are from the second Mattermost instance. I had to restore the first instance back to working 5.25.0.  
After taking a backup and restoring onto second instance (Another Bitnami image which was launched at 5.32.1 on Debian 10) After restoring using the documentation, the second instance also worked fine. I am getting this issue when I upgrade the second instance.

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 2:53am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/5 "2021-03-02T02:53:34Z")

</div>

Also what do I enter as password for the 3rd check you mentioned?  
I tried the bitnami credentials I got when I launched the instance but it doesnt seem to work

 ![m3](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/9/97d2806fc3b53cf1088d5f6501f0853a10c62450.png)

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 2, 2021, 3:14am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/6 "2021-03-02T03:14:38Z")

</div>

Hi, @k0ushik

The `ls -lAh /var/lib/mysql | grep "<database_name>"` is to be ran on the server hosting your Mattermost database. I noticed from your configuration that it is on localhost. Can I please confirm where is your MySQL database being stored in that machine? By default, it is stored in `/var/lib/mysql` which is why I shared to you the command earlier.

For the third check, you should be using the password you used to access your database. If I look at your example, it is `e47cb77d6`.

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 4:16am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/7 "2021-03-02T04:16:08Z")

</div>

I dont understand. This is just one instance. So that mattermost database is also on the same server. Do you mean my original instance who’s backup I restored here?

The password you gave doesnt work either:

 ![k1](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/a/a5a692ce419d1a24c48a3e4ea87baa3dbae78fad.png)

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 4:20am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/8 "2021-03-02T04:20:41Z")

</div>

Ok I have located mysql but theres no output for grep bitnami\_mattermost or mattermost

 ![t1](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/4/4f91651836b376e630bbc113685cd4f22012daad.png)

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 2, 2021, 4:55am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/9 "2021-03-02T04:55:10Z")

</div>

Hi, @k0ushik

That shows that there isn’t any database at all in the directory. How is the database actually being configured in the new instance?

- How did you access the MySQL backend in the original instance? What username and password did you use?

- What is the configuration like on this new instance? Is it self hosted on a Linux machine or it is still running on another Bitnami [deployment](https://docs.mattermost.com/install/deploy-bitnami.html) as well?

- If it is an a Linux machine, is the MySQL database that you are using to restore the information back hosted on the same machine? How do you access it?

When you mentioned this, what I understand here is that you are currently have a working Mattermost Server 5.25.7.

> [@k0ushik](#):
>
> This works and I am able to get the new instance working.

The specific issue that you are facing here is the database issue when you upgraded to 5.26.2. Just to double confirm that you did not miss any steps in the [Upgrade Mattermost Team Edition](https://docs.bitnami.com/general/apps/mattermost/administration/upgrade/) guide.

I went through the upgrade notes and the changelog of Mattermost, did not see any breaking changes that would affect the database when we move from the said versions.

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 5:34am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/10 "2021-03-02T05:34:26Z")

</div>

Hi, @ahmaddanial

> [@ahmaddanial](#):
>
> - How did you access the MySQL backend in the original instance? What username and password did you use?

I did not access the MySQL while backing up. I just got application-backup.tar.gz which I then unzipped on new instance. Then I restarted all services using the ctlscript.sh restart command.

> [@ahmaddanial](#):
>
> - What is the configuration like on this new instance? Is it self hosted on a Linux machine or it is still running on another Bitnami [deployment](https://docs.mattermost.com/install/deploy-bitnami.html) as well?

I followed this: [Upgrade Mattermost Team Edition](https://docs.bitnami.com/general/apps/mattermost/administration/upgrade/)  
to take a backup from my Instance A which is Bitnami Mattermost Team Edition running on Ubuntu 14.04.  
Instance B is also a Bitnamo Mattermost Team Edition but this runs on Debian 10. As I didnt see the latest Ubuntu version support while configuring the new instance from AWS Marketplace.

> [@ahmaddanial](#):
>
> - If it is an a Linux machine, is the MySQL database that you are using to restore the information back hosted on the same machine? How do you access it?

I’m not sure how to access this mysql database. I have never done this before.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 2, 2021, 7:26am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/11 "2021-03-02T07:26:30Z")

</div>

Hello, @k0ushik

> [@k0ushik](#):
>
> I just got application-backup.tar.gz which I then unzipped on new instance. Then I restarted all services using the ctlscript.sh restart command.

I might be repeating myself but you did go through the rest of the steps prior to restarting the server, yes?

```auto
sudo cp /opt/bitnami/apps/mattermost/backup/config.json /opt/bitnami/apps/mattermost/server/config/config.json

```

```auto
sudo chown -R root:root /opt/bitnami/apps/mattermost/server
sudo touch /opt/bitnami/apps/mattermost/server/logs/mattermost.log
sudo chown -R bitnami:mattermost /opt/bitnami/apps/mattermost/server/logs
sudo chmod g+w /opt/bitnami/apps/mattermost/server/logs/mattermost.log
sudo chown -R bitnami:mattermost /opt/bitnami/apps/mattermost/server/client/
sudo chmod -R g+w /opt/bitnami/apps/mattermost/server/client/

```

Just want to make sure that there are no loose ends.

> [@k0ushik](#):
>
> but this runs on Debian 10

So, it’s on a different distro. I don’t see it as a problem since the error that we are seeing is specific to the database table.

> [@k0ushik](#):
>
> I’m not sure how to access this mysql database. I have never done this before.

Do you have any database administrator who is helping you with the original Mattermost setup, migration. and upgrade that we can get involve in this discussion?

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 8:07am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/12 "2021-03-02T08:07:26Z")

</div>

Yes I have followed all steps in the upgrade procedure. All the steps.  
I have managed this instance since a long time(no separate database admin). I have never had the need to access the database so I’m not sure if I have any such credentials. I can look in my previous notes if I have saved any such configurations.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 2, 2021, 8:12am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/13 "2021-03-02T08:12:39Z")

</div>

Hi, @k0ushik

Got it. I would like to check the database side of it based on the error you shared. Hence, the database access that I asked. All the steps were followed correctly based on the documentation provided by Bitnami themselves, so there should not be any issues there.

Side note: Can you attempt to upgrade the working 5.25.7 to the latest version and confirm if you are still hitting into the same problem? Just trying to further isolate if this is a Mattermost Server specific or rather something else (like database in discussion now).

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 4:21pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/14 "2021-03-02T16:21:12Z")

</div>

Sure @ahmaddanial I will try this again. Full you mean try upgrading directly from 5.25 to 5.32? Or just finish the whole upgrade path on existing instance which is on 5.26??

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 7:40pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/15 "2021-03-02T19:40:33Z")

</div>

I am trying to restore backup onto the second instance again. Will update how it went

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 9:43pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/16 "2021-03-02T21:43:53Z")

</div>

Hey @ahmaddanial I restored the backup successfully again and got a working 5.25.0  
This time I followed the instructions here: [Upgrade Mattermost Team Edition](https://docs.bitnami.com/general/apps/mattermost/administration/upgrade/)  
But this time as mentioned in the article, I directly tried mattermost 5.32.1. This also breaks mattermost and I get mattermost could not be started. Also, there is nothing in mattermost.log file. I was getting some issues in nginx(related to new domain resolution) which I think I have resolved. So nginx starts, but mattermost still does not start. Please advise.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 2, 2021, 10:25pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/17 "2021-03-02T22:25:26Z")

</div>

Hello, @k0ushik

Clearly something is missing in the upgrade documentation because it continues to fail. If there is nothing in the `mattermost.log` file, we do not have any information to start troubleshooting the issue from Mattermost Server side.

Can you please confirm if your logging in Mattermost is set to the following, specifically the `FileLevel` set to `DEBUG` so more information is logged to the `mattermost.log`?

```auto
    "LogSettings": {
        "EnableConsole": true,
        "ConsoleLevel": "DEBUG",
        "ConsoleJson": false,
        "EnableFile": true,
        "FileLevel": "DEBUG",
        "FileJson": true,
        "FileLocation": "",
        "EnableWebhookDebugging": true,
        "EnableDiagnostics": false,
        "EnableSentry": true,
        "AdvancedLoggingConfig": ""
    },

```

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 2, 2021, 10:32pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/18 "2021-03-02T22:32:08Z")

</div>

@ahmaddanial These are my settings: ![image](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/0/069cda4367b6ef8db1dc195ba393b1ac297da336.png)

Even after I change FileLevel to DEBUG, the mattermost log file is empty. I just get a 502 from NGINX when I visit the site

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [March 3, 2021, 1:35am UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/19 "2021-03-03T01:35:21Z")

</div>

Hello, @k0ushik

Got it. Since there is nothing much from Mattermost, please keep me posted on the **database access** so we can check on things there.

At the same time, I have reached out to the dev / engineering team as well to gather their thoughts on this issue.

---

<div class="post-metadata">

**Author:** ![k0ushik](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@k0ushik](https://forum.mattermost.com/u/k0ushik)\
**Post date:** [March 3, 2021, 6:37pm UTC](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316/20 "2021-03-03T18:37:36Z")

</div>

Hi @ahmaddanial I am not seeing any logs on mattermost as the log file is empty. So I dont know if the database issue is resolved. Can the dev /engineering team advise on how to debug this? Thanks!

[Next page](https://forum.mattermost.com/t/upgrading-from-5-25-0-mattermost-sql-error-creating-database-tables/11316.md?page=2)
