From version 8.0.13 onwards, the documentation says (emphasis is mine):
The
BLOB
,TEXT
,GEOMETRY
, andJSON
data types can be assigned a default value only if the value is written as an expression, even if the expression value is a literal.
You can make your default an expression by surrounding the literal value with parentheses:
ALTER TABLE templates CHANGE COLUMN values JSON NOT NULL DEFAULT ('{}') ;
Or:
ALTER TABLE templates CHANGE COLUMN values JSON NOT NULL DEFAULT (JSON_OBJECT()) ;
Prior to version 8.0.13 of MySQL, it was not possible to set a default value on a JSON column, as the 8.0 documentation points out a few paragraphs later :
The
BLOB
,TEXT
,GEOMETRY
, andJSON
data types cannot be assigned a default value.