MySQL Error 1074 occurs when a VARCHAR or CHAR column exceeds the maximum byte limit of 65,535 bytes. The actual character limit depends on your character set (UTF-8, GBK, Latin1), and can be reduced when using multi-byte encoding.
MySQL Error 1074 (SQLSTATE: 42000) is raised when you attempt to create or modify a table with a column length that exceeds MySQL's maximum allowed size. The error message indicates both the column name and the actual maximum length allowed, which varies based on the data type and character set. This is not a memory or hardware limitation, but rather a constraint built into MySQL's design. VARCHAR columns can store up to 65,535 bytes total, but this is a shared limit across all columns in a row. Additionally, when using multi-byte character encodings like UTF-8, the effective character limit is much lower because each character consumes multiple bytes. The error typically appears during table creation (CREATE TABLE) or when modifying a table structure (ALTER TABLE ... MODIFY COLUMN).
First, understand what character set your database or table uses and how many bytes each character requires. Run:
SHOW CREATE TABLE your_table_name\GLook for the CHARSET definition. Common character sets:
- latin1/iso-8859-1: 1 byte per character → max 65,535 character limit
- utf8mb3: 3 bytes per character → max 21,845 character limit (65,535 ÷ 3)
- utf8mb4: 4 bytes per character → max 16,383 character limit (65,535 ÷ 4)
- GBK: 2 bytes per character → max 32,767 character limit (65,535 ÷ 2)
The simplest fix is to reduce the declared size of your VARCHAR column to stay within limits. For UTF-8 databases, use VARCHAR(21845) or less:
-- Wrong (fails with Error 1074 on UTF-8)
CREATE TABLE users (
description VARCHAR(65535)
);
-- Correct (respects the 65,535 byte limit for UTF-8)
CREATE TABLE users (
description VARCHAR(21845)
);
-- Or use TEXT for unlimited length
CREATE TABLE users (
description TEXT
);For existing tables, use ALTER TABLE:
ALTER TABLE users MODIFY COLUMN description VARCHAR(21845);If you need to store more than your VARCHAR limit allows, use TEXT data types:
-- For content up to 65,535 bytes
CREATE TABLE articles (
content TEXT
);
-- For content up to 16MB
CREATE TABLE documents (
content MEDIUMTEXT
);
-- For content up to 4GB
CREATE TABLE archives (
content LONGTEXT
);TEXT types don't count toward the 65,535 byte row limit and can store much larger content. However, they're slightly slower to index and query compared to VARCHAR.
Remember that the 65,535 byte limit is shared across ALL columns in a row, not per column. If you have multiple large VARCHAR columns, they sum together:
-- This may fail if total > 65,535 bytes
CREATE TABLE products (
name VARCHAR(10000),
description VARCHAR(10000),
details VARCHAR(10000),
notes VARCHAR(10000),
comments VARCHAR(10000)
);
-- Total: 50,000 bytes - OK
-- This will fail
CREATE TABLE products (
name VARCHAR(20000),
description VARCHAR(20000),
details VARCHAR(20000),
notes VARCHAR(20000),
comments VARCHAR(20000)
);
-- Total: 100,000 bytes - EXCEEDS LIMITTo fix: either reduce individual VARCHAR sizes or move some columns to a separate table (normalization).
As a last resort, you can change your database or table to use a single-byte character set like Latin1, which allows VARCHAR(65535). However, this is rarely recommended because:
1. You lose support for Unicode characters
2. Modern applications expect UTF-8 support
3. It may break existing client code
If you must do this:
-- Change entire table to Latin1
ALTER TABLE users CONVERT TO CHARACTER SET latin1 COLLATE latin1_swedish_ci;
-- Or for a specific column
ALTER TABLE users MODIFY COLUMN description VARCHAR(65535) CHARACTER SET latin1;Only use this approach if you're certain you don't need Unicode support.
UTF-8 Variants: MySQL has three UTF-8 implementations. The legacy utf8 is actually utf8mb3 (3 bytes max). Use utf8mb4 (4 bytes) for full Unicode support including emojis. The byte limits are:
- utf8mb3: 65,535 ÷ 3 = 21,845 characters
- utf8mb4: 65,535 ÷ 4 = 16,383 characters
InnoDB Row Format: Different row formats have different maximum row sizes. COMPRESSED and DYNAMIC formats may have different limits than COMPACT. Check your table's row format with SHOW CREATE TABLE.
NULL and Storage Overhead: The actual space calculation includes a 1-2 byte length prefix for VARCHAR and potential NULL value storage. This can slightly reduce the effective maximum.
Migration Strategy: When converting large VARCHAR to TEXT, be aware that some applications may expect VARCHAR behavior (e.g., default collation handling). Test thoroughly before deploying to production.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions