How to Fix MySQL Error 1101: BLOB/TEXT Column Can't Have a Default Value

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

  1. Explicitly writing DEFAULT '' or DEFAULT NULL on a TEXT/BLOB column. Even DEFAULT NULL is rejected for BLOB and TEXT columns in strict mode (prior to MySQL 8.0.13, where DEFAULT NULL became legal for BLOB/TEXT). On MySQL 5.7, both non-null and null defaults are forbidden.

  2. ORM model definitions with a default on a large-object field. Django's TextField with default='', SQLAlchemy's Text column with server_default, Hibernate/JPA annotations with @Column(columnDefinition="TEXT DEFAULT ''"), and similar constructs all cause MySQL to emit this error when the ORM runs the CREATE TABLE DDL.

  3. 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.

  4. Altering an existing BLOB/TEXT column to add a default. ALTER TABLE t MODIFY COLUMN body TEXT DEFAULT '' fails for the same reason as CREATE TABLE.

  5. JSON columns with a DEFAULT value (MySQL 5.7). The JSON type 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

  1. 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 the CREATE TABLE or ALTER TABLE statement and find the DEFAULT clause on that column.

  2. 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 the DEFAULT NULL clause — MySQL treats unspecified BLOB/TEXT columns as NULL anyway when no value is supplied and the column is nullable.

  3. 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 ;
    
  4. 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; only DEFAULT NULL and expression defaults (e.g., DEFAULT ('') using expression syntax) are permitted.

  5. 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)
    
  6. Check your MySQL version if migrating schemas. Query the server version to understand which restrictions apply:

    SELECT VERSION();
    

    On 5.7 both DEFAULT NULL and DEFAULT '' are forbidden. On 8.0.13+ DEFAULT NULL is legal. On 8.0.13+ expression defaults using DEFAULT (<expr>) syntax are also supported for BLOB/TEXT.

Additional Information

  • The SQLSTATE code 42000 indicates 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, and JSON (on MySQL 5.7).
  • VARCHAR and CHAR columns are not affected — they accept DEFAULT values normally.
  • MySQL 8.0.13 introduced support for expression defaults (DEFAULT (<expression>)) on all column types including BLOB/TEXT, allowing DEFAULT ('') using expression syntax.
  • Replication: if you have a source running MySQL 8.0.13+ that allows DEFAULT NULL on 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.

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.

We use cookies to provide an optimized user experience and understand our traffic. To learn more, read our use of cookies; otherwise, please choose 'Accept Cookies' to continue using our website.