ERROR 1101 (42000): BLOB/TEXT column '<column_name>' can't have a default value is raised when a CREATE TABLE or ALTER TABLE statement attempts to assign a DEFAULT clause to a column of type BLOB, TEXT, GEOMETRY, or JSON. The error symbol is ER_BLOB_CANT_HAVE_DEFAULT.
Impact
The DDL statement fails immediately and no changes are made to the schema. This error surfaces during application bootstrapping or migration runs — most commonly when an ORM generates a schema from a model definition that includes a default on a large-object column, or when a schema migration file is ported from PostgreSQL or SQLite (both of which allow text column defaults).
In strict SQL mode (the default since MySQL 5.7.5) the error is always fatal. In older or permissive configurations the behavior depended on the NO_ZERO_DATE and related mode flags, but the restriction on BLOB/TEXT defaults has applied consistently across all versions of MySQL.
Common Causes
Explicitly writing
DEFAULT ''orDEFAULT NULLon a TEXT/BLOB column. EvenDEFAULT NULLis rejected for BLOB and TEXT columns in strict mode (prior to MySQL 8.0.13, whereDEFAULT NULLbecame legal forBLOB/TEXT). On MySQL 5.7, both non-null and null defaults are forbidden.ORM model definitions with a default on a large-object field. Django's
TextFieldwithdefault='', SQLAlchemy'sTextcolumn withserver_default, Hibernate/JPA annotations with@Column(columnDefinition="TEXT DEFAULT ''"), and similar constructs all cause MySQL to emit this error when the ORM runs theCREATE TABLEDDL.Schema migrations copied from another database engine. PostgreSQL permits
TEXT DEFAULT '', and dumping a Postgres schema then importing it into MySQL will fail on every TEXT column that carries a default.Altering an existing BLOB/TEXT column to add a default.
ALTER TABLE t MODIFY COLUMN body TEXT DEFAULT ''fails for the same reason asCREATE TABLE.JSON columns with a DEFAULT value (MySQL 5.7). The
JSONtype is stored internally as a BLOB-like type and shares the same restriction on MySQL 5.7. MySQL 8.0 introduced limited expression defaults for JSON (e.g.,DEFAULT (JSON_ARRAY())), but only via the expression-default syntax.
Troubleshooting and Resolution Steps
Identify the offending column in the failing statement. The error message names the column directly, e.g.,
BLOB/TEXT column 'body' can't have a default value. Locate theCREATE TABLEorALTER TABLEstatement and find theDEFAULTclause on that column.Remove the DEFAULT clause entirely.
-- Before (fails): CREATE TABLE articles ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, body TEXT NOT NULL DEFAULT '' ); -- After (works): CREATE TABLE articles ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, body TEXT NOT NULL );If the column must be nullable and callers rely on a default of
NULL, drop theDEFAULT NULLclause — MySQL treats unspecified BLOB/TEXT columns asNULLanyway when no value is supplied and the column is nullable.If you need a default, handle it in application code or a trigger. Since the column cannot carry a storage-level default, apply the default in the INSERT path:
-- Use a BEFORE INSERT trigger to supply the default DELIMITER $$ CREATE TRIGGER set_body_default BEFORE INSERT ON articles FOR EACH ROW BEGIN IF NEW.body IS NULL THEN SET NEW.body = ''; END IF; END$$ DELIMITER ;For MySQL 8.0.13+, DEFAULT NULL is now legal for BLOB/TEXT. If you are running MySQL 8.0.13 or later and only need a null default, the following is accepted:
CREATE TABLE articles ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, body TEXT DEFAULT NULL );Non-null literal defaults (e.g.,
DEFAULT '') remain unsupported; onlyDEFAULT NULLand expression defaults (e.g.,DEFAULT ('')using expression syntax) are permitted.Fix ORM model definitions. Remove or override the server-side default in the ORM layer and rely on application-level defaults instead:
# Django — remove default= from the model field or use default only at the # Python layer, not as a db_default body = models.TextField(blank=True, default='') # application default only # SQLAlchemy — omit server_default for Text columns body = Column(Text, nullable=True)Check your MySQL version if migrating schemas. Query the server version to understand which restrictions apply:
SELECT VERSION();On 5.7 both
DEFAULT NULLandDEFAULT ''are forbidden. On 8.0.13+DEFAULT NULLis legal. On 8.0.13+ expression defaults usingDEFAULT (<expr>)syntax are also supported for BLOB/TEXT.
Additional Information
- The SQLSTATE code
42000indicates a syntax or access rule violation — the statement was structurally invalid, not blocked by a runtime constraint. - The affected types are
TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB,TINYTEXT,TEXT,MEDIUMTEXT,LONGTEXT,GEOMETRY, andJSON(on MySQL 5.7). VARCHARandCHARcolumns are not affected — they acceptDEFAULTvalues normally.- MySQL 8.0.13 introduced support for expression defaults (
DEFAULT (<expression>)) on all column types including BLOB/TEXT, allowingDEFAULT ('')using expression syntax. - Replication: if you have a source running MySQL 8.0.13+ that allows
DEFAULT NULLon TEXT columns and a replica on 5.7, the DDL will fail on the replica. - When importing a mysqldump from MySQL 8.0+ into 5.7, watch for TEXT/BLOB columns with
DEFAULT NULL— they will cause import failures.
Frequently Asked Questions
Why does MySQL not allow defaults on TEXT and BLOB columns? MySQL's storage engine stores BLOB and TEXT column values off-row (in separate pages for larger values). Because these types have variable length and may be very large, MySQL historically did not support inline literal defaults for them. The restriction was a design decision in the original engine that was only partially relaxed in MySQL 8.0.13.
Can I use DEFAULT NULL on a TEXT column?
On MySQL 5.7, no — DEFAULT NULL is also rejected. On MySQL 8.0.13 and later, DEFAULT NULL is permitted for BLOB and TEXT columns. You can check your version with SELECT VERSION();.
My ORM creates the column with a default and it works in development (SQLite/Postgres) but fails in production (MySQL). What should I do?
The safest fix is to remove the server-side default from the ORM column definition and enforce the default purely at the application layer. In Django use default= (not db_default=); in SQLAlchemy omit server_default. This keeps behaviour consistent across database backends.
Does this affect JSON columns?
Yes, on MySQL 5.7 the JSON type shares the same restriction. On MySQL 8.0 you can use expression-default syntax: DEFAULT (JSON_OBJECT()) or DEFAULT (JSON_ARRAY()), but not a plain literal default.