首先先備份原來的 Table:
use nextcloud;
RENAME TABLE oc_filecache TO oc_filecache_bak;
CREATE TABLE oc_filecache SELECT * FROM oc_filecache_bak LIMIT 0
再使用 occ 指令重建 oc_filecache:
sudo -u www-data ./occ files:scan --all
這時候可能會遇到 mysql 超時:
Exception during scan: An exception occurred while executing 'DELETE FROM `oc_filecache` WHERE `fileid` = ?' with params [null]:
SQLSTATE[08S01]: Communication link failure: 1053 Server shutdown in progress
去修改 /etc/my.cnf.d/server.cnf
,在 [mysqld]
下面新增:
[mysqld]
innodb_lock_wait_timeout=360
...
重啟 MariaDB:
systemctl restart mariadb
再重建一次,檔案越多,需要更長的 timeout 時間,不然的話會跑不完阿(J1900 QQ)