You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next Cloud安装报错:创建管理员用户失败(SQL键过长问题)

Fixing "Specified key was too long" Error When Installing NextCloud on InfinityFree

I've run into this exact issue with NextCloud on InfinityFree before—here's how to resolve it:

What's Causing the Error?

The problem stems from a mismatch between NextCloud's default database schema and the limitations of the older MySQL version used by InfinityFree.

NextCloud tries to create the oc_migrations table with a primary key made of two VARCHAR(255) fields. When using UTF8 encoding (required for NextCloud), each character takes up 3 bytes. This makes the total length of the primary key 255*3*2 = 1530 bytes—way over the 1000-byte max key length limit for InnoDB in older MySQL versions.

This is the cleanest fix, as it lets you keep UTF8 encoding while working within the host's constraints:

  1. Log into your InfinityFree cPanel and open phpMyAdmin.
  2. Select the database you created for NextCloud.
  3. Paste this SQL query into the query editor and run it:
CREATE TABLE oc_migrations (
    app VARCHAR(166) NOT NULL,
    version VARCHAR(166) NOT NULL,
    PRIMARY KEY(app, version)
) DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin ENGINE = InnoDB;

We've reduced the field length to 166—this brings the total key length to 166*3*2 = 996 bytes, which fits under the 1000-byte limit.
4. Go back to the NextCloud installation page, re-enter your admin and database details, and click install. The installer will detect the existing oc_migrations table and skip creating it, avoiding the error.

Solution 2: Temporary Character Set Switch (For Testing Only)

If you just need a quick test setup, you can temporarily switch your database to use latin1 encoding (each character uses 1 byte, so the 255-length fields will only take 510 bytes total):

  1. In phpMyAdmin, edit your database's default character set to latin1 and collation to latin1_swedish_ci.
  2. Run the NextCloud installer as normal.
  3. Important: After installation, you'll need to manually convert all tables back to UTF8/utf8mb4 to support non-ASCII characters (this is tedious, so only use this for quick tests).

内容的提问来源于stack exchange,提问作者Chad Fernandez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:05:00