Fail to upgrade to 6.4.1 - SOLVED

Cannot upgrade from 6.3.4 to 6.4.1

I have a small VPS with Mattermost 6.3.4 installed alongside with the database (10.4.24-MariaDB). I follow the usual steps to upgrade but the service won’t start:

systemctl status mattermost.service -l
● mattermost.service - Mattermost
Loaded: loaded (/etc/systemd/system/mattermost.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since lun. 2022-03-07 07:20:28 CET; 44s ago
Process: 7781 ExecStart=/opt/mattermost/bin/mattermost (code=exited, status=1/FAILURE)
Main PID: 7781 (code=exited, status=1/FAILURE)

mars 07 07:20:27 *** systemd[1]: Starting Mattermost…
mars 07 07:20:28 *** mattermost[7781]: {“timestamp”:“2022-03-07 07:20:28.130 +01:00”,“level”:“info”,“msg”:“Server is initializing…”,“caller”:“app/server.go:237”,“go_version”:“go1.16.7”}
mars 07 07:20:28 *** mattermost[7781]: {“timestamp”:“2022-03-07 07:20:28.131 +01:00”,“level”:“info”,“msg”:“Starting websocket hubs”,“caller”:“app/web_hub.go:93”,“number_of_hubs”:2}
mars 07 07:20:28 *** mattermost[7781]: {“timestamp”:“2022-03-07 07:20:28.131 +01:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sqlstore/store.go:215”,“database”:“master”}
mars 07 07:20:28 *** mattermost[7781]: {“timestamp”:“2022-03-07 07:20:28.197 +01:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sqlstore/store.go:215”,“database”:“master”}
mars 07 07:20:28 *** mattermost[7781]: 2022/03/07 07:20:28 == create_commands: migrating ====================================================================
mars 07 07:20:28 *** systemd[1]: mattermost.service: main process exited, code=exited, status=1/FAILURE
mars 07 07:20:28 *** systemd[1]: Failed to start Mattermost.
mars 07 07:20:28 *** systemd[1]: Unit mattermost.service entered failed state.
mars 07 07:20:28 *** systemd[1]: mattermost.service failed.

I updated the database with
ALTER DATABASE <YOUR_DB_NAME> COLLATE = 'utf8mb4_general_ci',

I have the following log, which tells me to use mysql_upgrade to fix this error:
{“timestamp”:“2022-03-07 07:17:39.238 +01:00”,“level”:“info”,“msg”:“Stopping Server…”,“caller”:“app/server.go:922”}
{“timestamp”:“2022-03-07 07:17:39.239 +01:00”,“level”:“info”,“msg”:“stopping websocket hub connections”,“caller”:“app/web_hub.go:113”}
{“timestamp”:“2022-03-07 07:17:39.243 +01:00”,“level”:“error”,“msg”:“RPC call OnWebSocketDisconnect to plugin failed.”,“caller”:“plugin/client_rpc_generated.go:620”,“plugin_id”:“focalboard”,“error”:“connection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.328 +01:00”,“level”:“info”,“msg”:“Stopped workers”,“caller”:“jobs/workers.go:353”}
{“timestamp”:“2022-03-07 07:17:39.328 +01:00”,“level”:“info”,“msg”:“Stopping schedulers.”,“caller”:“jobs/schedulers.go:187”}
{“timestamp”:“2022-03-07 07:17:39.328 +01:00”,“level”:“info”,“msg”:“Schedulers stopped.”,“caller”:“jobs/schedulers.go:119”}
{“timestamp”:“2022-03-07 07:17:39.329 +01:00”,“level”:“info”,“msg”:“Server stopped”,“caller”:“app/server.go:1002”}
{“timestamp”:“2022-03-07 07:17:39.329 +01:00”,“level”:“info”,“msg”:“Shutting down plugins”,“caller”:“app/plugin.go:339”}
{“timestamp”:“2022-03-07 07:17:39.344 +01:00”,“level”:“error”,“msg”:“RPC call OnDeactivate to plugin failed.”,“caller”:“plugin/client_rpc_generated.go:33”,“plugin_id”:“com.github.matterpoll.matterpoll”,“error”:“connection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.344 +01:00”,“level”:“warn”,“msg”:“error closing client during Kill”,“caller”:“plugin/hclog_adapter.go:70”,“plugin_id”:“com.github.matterpoll.matterpoll”,“wrapped_extras”:“errconnection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.344 +01:00”,“level”:“warn”,“msg”:“plugin failed to exit gracefully”,“caller”:“plugin/hclog_adapter.go:72”,“plugin_id”:“com.github.matterpoll.matterpoll”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“error closing client during Kill”,“caller”:“plugin/hclog_adapter.go:70”,“plugin_id”:“com.mattermost.plugin-channel-export”,“wrapped_extras”:“errconnection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“plugin failed to exit gracefully”,“caller”:“plugin/hclog_adapter.go:72”,“plugin_id”:“com.mattermost.plugin-channel-export”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“error”,“msg”:“RPC call OnDeactivate to plugin failed.”,“caller”:“plugin/client_rpc_generated.go:33”,“plugin_id”:“com.mattermost.nps”,“error”:“connection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“error closing client during Kill”,“caller”:“plugin/hclog_adapter.go:70”,“plugin_id”:“com.mattermost.nps”,“wrapped_extras”:“errconnection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“plugin failed to exit gracefully”,“caller”:“plugin/hclog_adapter.go:72”,“plugin_id”:“com.mattermost.nps”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“error closing client during Kill”,“caller”:“plugin/hclog_adapter.go:70”,“plugin_id”:“playbooks”,“wrapped_extras”:“errconnection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“plugin failed to exit gracefully”,“caller”:“plugin/hclog_adapter.go:72”,“plugin_id”:“playbooks”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“error”,“msg”:“RPC call OnDeactivate to plugin failed.”,“caller”:“plugin/client_rpc_generated.go:33”,“plugin_id”:“focalboard”,“error”:“connection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“error closing client during Kill”,“caller”:“plugin/hclog_adapter.go:70”,“plugin_id”:“focalboard”,“wrapped_extras”:“errconnection is shut down”}
{“timestamp”:“2022-03-07 07:17:39.346 +01:00”,“level”:“warn”,“msg”:“plugin failed to exit gracefully”,“caller”:“plugin/hclog_adapter.go:72”,“plugin_id”:“focalboard”}
{“timestamp”:“2022-03-07 07:20:28.130 +01:00”,“level”:“info”,“msg”:“Server is initializing…”,“caller”:“app/server.go:237”,“go_version”:“go1.16.7”}
{“timestamp”:“2022-03-07 07:20:28.131 +01:00”,“level”:“info”,“msg”:“Starting websocket hubs”,“caller”:“app/web_hub.go:93”,“number_of_hubs”:2}
{“timestamp”:“2022-03-07 07:20:28.131 +01:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sqlstore/store.go:215”,“database”:“master”}
{“timestamp”:“2022-03-07 07:20:28.197 +01:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sqlstore/store.go:215”,“database”:“master”}
{“timestamp”:“2022-03-07 07:20:28.446 +01:00”,“level”:“fatal”,“msg”:“Failed to apply database migrations.”,“caller”:“sqlstore/store.go:157”,“error”:“driver: mysql, message: failed when applying migration, command: apply_migration, originalError: Error 1558: Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 50565, now running 100424. Please use mysql_upgrade to fix this error, query: \n\nCREATE TABLE IF NOT EXISTS Commands (\n Id varchar(26) NOT NULL,\n Token varchar(26) DEFAULT NULL,\n CreateAt bigint(20) DEFAULT NULL,\n UpdateAt bigint(20) DEFAULT NULL,\n DeleteAt bigint(20) DEFAULT NULL,\n CreatorId varchar(26) DEFAULT NULL,\n TeamId varchar(26) DEFAULT NULL,\n Trigger varchar(128) DEFAULT NULL,\n Method varchar(1) DEFAULT NULL,\n Username varchar(64) DEFAULT NULL,\n IconURL text,\n AutoComplete tinyint(1) DEFAULT NULL,\n AutoCompleteDesc text,\n AutoCompleteHint text,\n DisplayName varchar(64) DEFAULT NULL,\n Description varchar(128) DEFAULT NULL,\n URL text,\n PRIMARY KEY (Id),\n KEY idx_command_team_id (TeamId),\n KEY idx_command_update_at (UpdateAt),\n KEY idx_command_create_at (CreateAt),\n KEY idx_command_delete_at (DeleteAt)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n\nSET @preparedStatement = (SELECT IF(\n (\n SELECT COUNT() FROM INFORMATION_SCHEMA.COLUMNS\n WHERE table_name = ‘Commands’\n AND table_schema = DATABASE()\n AND column_name = ‘PluginId’\n ) > 0,\n ‘SELECT 1’,\n ‘ALTER TABLE Commands ADD PluginId varchar(190);’\n));\n\nPREPARE alterIfNotExists FROM @preparedStatement;\nEXECUTE alterIfNotExists;\nDEALLOCATE PREPARE alterIfNotExists;\n\nCREATE PROCEDURE Migrate_If_Version_Below_5280 ()\nBEGIN\nDECLARE\n\tCURRENT_DB_VERSION TEXT;\nDECLARE\n SYSTEMS_TABLE_EXISTS INT;\n SELECT COUNT()\n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE\n TABLE_NAME = ‘Systems’\n AND table_schema = DATABASE() INTO SYSTEMS_TABLE_EXISTS;\n IF (SYSTEMS_TABLE_EXISTS > 0) THEN\n\t SELECT\n\t\t Value\n\t FROM\n\t\t Systems\n\t WHERE\n\t\t Name = ‘Version’ INTO CURRENT_DB_VERSION;\n\t IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON(‘5.28.0’)) THEN\n\t\t UPDATE Commands SET PluginId = ‘’ WHERE PluginId IS NULL;\n\t END IF;\n END IF;\nEND;\n\tCALL Migrate_If_Version_Below_5280 ();\n\tDROP PROCEDURE IF EXISTS Migrate_If_Version_Below_5280;\n\n”}

Thank you for your help!

Solved with
mysql_upgrade -u root -p
service mysqld restart