Sample Header Ad - 728x90

How to disable max key length error in mysql

0 votes
2 answers
160 views
I use a google could sql (mysql) as my production database. To replicate this database for testing in docker i use the mysql:8 image. I noticed that one of my migration scripts succedes on the cloud db but failes during tests. The following script causes an error: CREATE TABLE testTable ( name varchar(1000) ); CREATE INDEX idx_device_designs_name ON testTable (name); The error: Specified key was too long; max key length is 3072 bytes [Failed SQL: (1071)... I understand the reason for the error, but as our standard production db does not produce it I'm looking for the setting that disables this check. **EDIT 1:** SELECT VERSION(); -> 8.0.31-google SHOW CREATE TABLE tableName production CREATE TABLE testTable ( name varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL, KEY idx_device_designs_name (name), ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci docker container CREATE TABLE testTable ( name varchar(1000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci production had the index applied in the past (before a mysql update, so 5.7). SHOW TABLE STATUS LIKE 'testTable' (on production) testTable,InnoDB,10,Dynamic,2,8192,16384,0,32768,0,3,2024-11-14 08:52:26,,,utf8mb3_unicode_ci,,"",""
Asked by Laures (113 rep)
Jan 30, 2025, 03:39 PM
Last activity: Jan 30, 2025, 08:12 PM