1048 🐬 MySQL

MySQL ERROR 1048 (23000): Column 'x' cannot be null

An INSERT/UPDATE put NULL into a NOT NULL column.

Seen on: MySQL

Meaning

Missing form fields, ORM attributes not set, or explicit NULL from the application.

Common causes

  • Required field missing from input
  • ORM model attribute not assigned
  • Explicit NULL instead of omitting the column (default not applied)

⚡ Quick fix

  1. Validate required fields
  2. Provide a default in the schema
  3. Omit the column to use its DEFAULT

Detailed fix by platform

MySQL

  1. ALTER TABLE users MODIFY status VARCHAR(20) NOT NULL DEFAULT 'active';

How to diagnose

  1. Column — Which one?
  2. Input — Why is it null?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.