Nextcloud升级报错数据库中不正确的行格式ROW_FORMAT=Dynamic

升级到Nextcloud Hub 10 (31.0.2)版本后数据库报错,报错内容如下:

在你的数据库中找到了不正确的行格式。ROW_FORMAT=Dynamic 可以让 Nextcloud 数据库性能最佳。请更新下表中的行格式:

官方文档链接指向mysql官方文档,无果,在社区找到几个帖子。

Frequent Nextcloud 31 (Hub 10) update issues – ℹ️ Support – Nextcloud community

Falsches Zeilenformat – 🌐 International support / 🇩🇪 Deutsch (german) – Nextcloud community

Nach Update auf 31.0 Falsches Zeilenformat in deiner Datenbank gefunden – 🌐 International support / 🇩🇪 Deutsch (german) – Nextcloud community

Upgrade to Nextcloud Hub 10 (31.0.0) Incorrect row format found in your database – ℹ️ Support – Nextcloud community

Add setup warning in case row_format=compressed is still used · Issue #34497 · nextcloud/server

实际上这个问题不应当出现,24版本后就应该不存在该问题。

这个数据库转换应该在occ maintenance:repair --include-expensive命令中自动包含而不应该让普通用户直接操作数据库,目前该命令尚不能自动修复该错误。

最后给出的解决方法是使用如下脚本:

#!/bin/bash

# Prompt for database credentials
read -p "Enter Database Name: " DB_NAME
read -p "Enter Username: " DB_USER
read -s -p "Enter Password: " DB_PASS
echo

# Execute all ALTER TABLE statements in one query
mysql -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" -Bse "
SELECT CONCAT('ALTER TABLE \`', TABLE_NAME, '\` ROW_FORMAT=DYNAMIC;') 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = '$DB_NAME' 
AND ENGINE = 'InnoDB'
" | mysql -u "$DB_USER" -p"$DB_PASS" "$DB_NAME"

以上方法来自用户bb77YannicK_SupRavII

另外Nextcloud Falsches Zeilenformat ROW_FORMAT=Dynamic – Got tty也提到上述方法。