<p>The error occurs when a CREATE UNIQUE INDEX statement uses the IGNORE keyword without specifying ALGORITHM=COPY in MySQL 5.7.4+.</p>
<p>MySQL Error 1852 ER_UNUSED6 appears when you run CREATE UNIQUE INDEX ... IGNORE without ALGORITHM=COPY. MySQL 5.7.4 and later enforce COPY to safely remove duplicates. Rewrite the statement with ALGORITHM=COPY or drop IGNORE after de-duplicating data to resolve the issue.</p>
Creating unique indexes with IGNORE requires COPY
Error 1852 fires when you attempt to create a unique index using the IGNORE modifier but omit ALGORITHM=COPY. Starting in MySQL 5.7.4, the server needs the COPY algorithm to copy the table, eliminate duplicate rows, and then build the new unique index.
The IGNORE keyword tells MySQL to silently drop duplicate rows that violate uniqueness. Without COPY, the in-place algorithm cannot discard offending rows, so the server raises ER_UNUSED6 to stop the operation.
If you ignore the restriction and force an in-place index build, duplicate rows could corrupt data integrity. MySQL blocks the unsafe path, prompting you to choose COPY or clean data first. Fixing the error ensures consistent, duplicate-free tables and reliable query plans.
Developers usually see Error 1852 during schema migrations that add unique constraints on large tables containing historical duplicates. Tools like pt-online-schema-change or manual ALTER TABLE scripts that append IGNORE without the proper algorithm also trigger it.
Using IGNORE with CREATE UNIQUE INDEX but omitting ALGORITHM=COPY is the primary trigger. MySQL rejects ALGORITHM=INPLACE for this operation because it cannot drop duplicate rows in-place.
The error can also surface if the server default algorithm is INPLACE and you explicitly add IGNORE, relying on default behavior instead of stating ALGORITHM=COPY.
Add ALGORITHM=COPY to the CREATE UNIQUE INDEX statement when you need IGNORE. The server copies the table, removes duplicates, and builds the index safely.
Alternatively, run a deduplication query first, remove IGNORE, and then create the unique index with ALGORITHM=INPLACE or default.
On busy production tables, COPY can lock writes longer. Use pt-online-schema-change or gh-ost to perform online migrations with COPY semantics and minimal downtime.
If dataset size is small, a simple CREATE UNIQUE INDEX ... ALGORITHM=COPY IGNORE is often fastest and safest.
Always inspect data for duplicates before adding unique constraints. Remove IGNORE when data is already clean.
Adopt explicit algorithm clauses in migrations. Pin versions in CI to catch breaking changes like this early.
Error 1831 arises when a duplicate column name exists during ALTER TABLE. Clean up or rename columns before re-attempting.
Error 1062 Duplicate entry occurs when inserting data that violates an existing unique index. Deduplicate the input or adjust the key definition.
The IGNORE modifier mandates COPY, but many migrations rely on default INPLACE.
Older deployment scripts written for MySQL 5.6 still use IGNORE without COPY.
Tables with hidden duplicate rows require COPY to drop them during index creation.
Raised when inserting a row that violates an existing unique index.
Occurs during ALTER TABLE when the new column conflicts with an existing name.
Triggered when referenced index types or lengths do not match between parent and child tables.
No. MySQL blocks that path to protect data integrity. Use COPY or remove IGNORE.
COPY blocks writes because it copies the whole table. Use online schema change tools to reduce lock time in production.
No. The requirement still exists in 8.0. You must use COPY with IGNORE, or deduplicate data first.
Galaxy flags CREATE UNIQUE INDEX scripts that combine IGNORE without ALGORITHM=COPY, suggesting a corrected statement in real time.