How to Fix MySQL Error 1101 (ER_BLOB_CANT_HAVE_DEFAULT)
You trigger mysql error 1101 when you assign a literal default value to a BLOB, TEXT, GEOMETRY, or JSON column. You can fix this error by removing the default value from the column definition or using a smaller column type. Database teams often see this failure during schema migrations. The engine blocks the table change and returns SQLSTATE 42000 with the ER_BLOB_CANT_HAVE_DEFAULT symbol. Understanding how the storage engine handles large objects helps you avoid deployment delays. What cause
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You trigger mysql error 1101 when you assign a literal default value to a BLOB, TEXT, GEOMETRY, or JSON column. You can fix this error by removing the default value from the column definition or using a smaller column type.
Database teams often see this failure during schema migrations. The engine blocks the table change and returns SQLSTATE 42000 with the ER_BLOB_CANT_HAVE_DEFAULT symbol. Understanding how the storage engine handles large objects helps you avoid deployment delays.
What causes mysql error 1101 in the database engine
MySQL stores BLOB, TEXT, GEOMETRY, and JSON data differently than standard strings or numbers. Fixed-length and short variable-length columns live right inside the main row buffer. Large variable-length columns get stored in separate memory pages outside the primary row.
Because the engine keeps these large values off-page, it rejects literal default values in strict mode. When you run a schema update that sets a constant default on these types, the parser stops the query. It then outputs the message stating that the column cannot have a default value.
Object-relational mappers often cause this problem during automated builds. A developer might add a text field in the app model and set an empty string as the default. The migration tool then generates an invalid table definition that fails on execution.
Differences in server SQL modes also cause surprises between staging and production. If a local database runs with relaxed SQL rules, it might only show a warning. When the same script runs on a strict production cluster, the engine blocks the change and throws error 1101.
How to diagnose and fix the failure in production
First, check your migration script or table creation query for the exact column name in the error message. Look at the data type assigned to that column. Ask your team if the column really needs to hold huge amounts of text or binary data.
If the column only stores short strings like status codes or titles, switch the type to VARCHAR. Standard variable-length string columns support literal default values without any issues. This simple change lets your schema update pass while keeping the default rule in the database.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
If you must use BLOB, TEXT, GEOMETRY, or JSON, remove the default clause from the schema definition. Instead, set the default value inside your app logic before the app sends write queries to the database. This approach works across all database releases and keeps your migration scripts clean.
In newer database releases, the engine allows default values on these types only if you write the default as an expression. Instead of a raw string literal, you wrap the value inside parentheses so the engine evaluates it as an expression. Check your database release notes to confirm if your cluster supports expression defaults.
How to prevent schema errors during deployments
Never disable strict SQL modes in production just to push a failing migration through. Turning off strict checks can lead to truncated data and silent write errors across your whole system. Always fix the schema definition itself rather than lowering database safety rules.
Match your local and staging database settings with your production cluster. When every test database enforces strict mode, developers catch invalid column defaults on their own machines. You should also review schema changes in pull requests before running them on live tables.
When engineers inspect production schemas to check column types, make sure your query tools protect sensitive data. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in query results. This lets your team check table structures and sample rows safely during an incident.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.
Frequently asked questions
Why did my migration work in staging but fail with error 1101 in production?
Your staging server likely runs without strict SQL mode enabled, which turns this error into a warning. Production databases enforce strict mode by default and reject the invalid column definition right away.
Can I use an empty string as a default for a TEXT column?
No, the database engine treats an empty string literal the same as any other constant default value. You must remove the default clause, switch to a VARCHAR column, or use a valid expression default if your server supports it.
Does error 1101 affect JSON columns in the same way as TEXT columns?
Yes, the official ER_BLOB_CANT_HAVE_DEFAULT rule applies to BLOB, TEXT, GEOMETRY, and JSON columns alike. You cannot assign a literal default value to a JSON column in a standard table definition.
Related guides
In this post