ERROR 1059 (42000): Identifier name '<name>' is too long is raised when an identifier — such as a database, table, column, index, constraint, or alias name — exceeds MySQL's hard limit of 64 characters. The error symbol is ER_TOO_LONG_IDENT.
Impact
The statement that triggers this error is rejected entirely; no DDL change or DML row is written. Because the error occurs at parse/execution time, it surfaces immediately rather than silently truncating the name.
This error most often appears during schema migrations. ORMs like Hibernate, SQLAlchemy, and Django generate index and constraint names by concatenating table and column names, and the resulting strings can easily exceed 64 characters for tables with long names or composite indexes. Migration tools such as Flyway and Liquibase will halt the migration and report the error, requiring manual intervention before the deployment can proceed.
Common Causes
Auto-generated index or constraint names. ORMs generate names like
ix_user_account_profile_settings_last_login_timestamp, which can easily exceed 64 characters when table names, column names, or both are long.Long column or table names written by hand. Descriptive naming conventions in large teams sometimes produce names like
customer_shipping_address_secondary_street_line(46 chars — fine on its own, but concatenated into an index name it overflows).Migration scripts ported from PostgreSQL. PostgreSQL also has a 63-byte identifier limit, but silently truncates names that exceed it. A migration written for Postgres may include explicitly long names that MySQL rejects rather than truncates.
Aliases in queries. Column aliases in
SELECTare also identifiers. An alias longer than 64 characters — uncommon but possible in generated queries — triggers the same error.Generated column names in
CREATE TABLE ... SELECT. When MySQL derives a column name from a complex expression, the derived name can exceed the limit.
Troubleshooting and Resolution Steps
Identify the offending identifier. The error message includes the name in single quotes, so the exact string is always visible:
ERROR 1059 (42000): Identifier name 'ix_customer_account_billing_address_last_updated_at_idx' is too longCount the characters or check with a quick query:
SELECT CHAR_LENGTH('ix_customer_account_billing_address_last_updated_at_idx') AS len; -- Returns 56 — within limit -- If it returns > 64, that is your problemRename the identifier to 64 characters or fewer. Shorten the name while keeping it descriptive:
-- Too long (67 chars): CREATE INDEX ix_customer_account_billing_address_last_updated_at_index ON customer_account (billing_address_last_updated_at); -- Fixed (abbreviated): CREATE INDEX ix_cust_acct_billing_addr_updated_at ON customer_account (billing_address_last_updated_at);Override ORM-generated names. Most ORMs allow explicit index/constraint names. Use them when the auto-generated name is too long.
Django example:
class Meta: indexes = [ models.Index( fields=["billing_address_last_updated_at"], name="cust_acct_billing_updated_idx", # explicit, short name ) ]SQLAlchemy example:
Index("cust_acct_billing_updated_idx", CustomerAccount.billing_address_last_updated_at)Check existing identifiers that are close to the limit. If you are refactoring and adding prefixes to existing objects, check whether any names are already near 64 characters:
-- Columns close to or at the limit SELECT table_schema, table_name, column_name, CHAR_LENGTH(column_name) AS len FROM information_schema.columns WHERE table_schema = 'your_database' AND CHAR_LENGTH(column_name) > 50 ORDER BY len DESC; -- Indexes close to or at the limit SELECT table_schema, table_name, index_name, CHAR_LENGTH(index_name) AS len FROM information_schema.statistics WHERE table_schema = 'your_database' AND CHAR_LENGTH(index_name) > 50 ORDER BY len DESC;Rename an existing object that already exceeds 64 characters (possible if the row was inserted via a storage engine bypass or an older MySQL version). Use
ALTER TABLE:ALTER TABLE orders RENAME COLUMN very_long_column_name_that_somehow_got_in_here_accidentally TO short_column_name;
Additional Information
- The 64-character limit applies to: database names, table names, column names, index names, constraint names (foreign key, check, unique), alias names, stored procedure and function names, trigger names, event names, and view names.
- The limit is defined in bytes for some character sets, but for identifiers MySQL uses the character count against 64, so multi-byte characters in identifier names count as one character each toward the limit (the actual byte cap is 192 bytes for utf8mb3 identifiers).
- Aliases used in query results (
SELECT expr AS alias) are subject to the same limit. Aliases longer than 64 characters produceERROR 1059rather than a warning. - MySQL does not silently truncate identifier names the way PostgreSQL does. The statement is rejected, making the error deterministic and easy to catch in testing.
- This error has the SQLSTATE
42000("syntax error or access rule violation"), the same class used for syntax errors, so some generic error handlers may conflate it with a parse error. - Related error:
ERROR 1166 (42000): Incorrect column name— raised when a column name contains an illegal character, as opposed to being too long.
Frequently Asked Questions
Why does MySQL have a 64-character limit on identifiers? The limit is a long-standing design constraint in MySQL's internal storage format, documented since MySQL 5.0. It applies consistently to all identifier types and has not been extended in subsequent versions, including MySQL 8.0 and 8.4. MariaDB shares the same limit.
My ORM creates index names longer than 64 characters on other databases. Why does MySQL fail? PostgreSQL silently truncates identifiers that exceed 63 bytes, so the same migration succeeds there without errors. MySQL rejects the statement outright. If your ORM targets multiple databases, you must either configure explicit short names or use a naming convention that stays within 64 characters for all backends.
Can I increase the 64-character limit? No. The limit is compiled into MySQL and cannot be changed via configuration. The only resolution is to shorten the identifier.
Does the 64-character limit apply to column aliases in SELECT?
Yes. SELECT very_long_expression AS <alias> raises ERROR 1059 if the alias exceeds 64 characters. This is uncommon in handwritten SQL but can appear in query builders or reporting tools that generate aliases from display names.