How to Fix MySQL Error 1264 (ER_WARN_DATA_OUT_OF_RANGE)
You get mysql error 1264 when a query writes a number outside a column limit. You can fix it by making the column larger or checking app input first. The database returns symbol ER_WARN_DATA_OUT_OF_RANGE and SQLSTATE 22003 when this failure occurs. The message states that an out of range value hit a column at a row. Strict mode stops the write right away to protect your stored records from corruption. Without strict mode, the database clips the number and saves the wrong value. Root causes of
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 get mysql error 1264 when a query writes a number outside a column limit. You can fix it by making the column larger or checking app input first.
The database returns symbol ER_WARN_DATA_OUT_OF_RANGE and SQLSTATE 22003 when this failure occurs. The message states that an out of range value hit a column at a row. Strict mode stops the write right away to protect your stored records from corruption. Without strict mode, the database clips the number and saves the wrong value.
Root causes of mysql error 1264 in your database
Every number column in a table has a strict minimum and maximum boundary. Integer columns have fixed byte sizes that cap the highest number they can hold. Signed columns allow negative numbers, which cuts the maximum positive limit in half. Unsigned columns block negative numbers and double the top limit for positive values. If an app sends a negative number to an unsigned column, the write fails.
Decimal and float columns also trigger this error when numbers exceed their scale. A decimal column sets a total digit count and a count of digits after decimals. The space left for whole numbers equals total digits minus the decimal digits. Sending one extra whole digit pushes the value past the column cap and fails.
Auto increment columns are another frequent source of this failure in growing tables. Each new row bumps an internal counter up by one until the column fills. Failed inserts also burn through counter numbers even when rows do not save. Once the counter hits the ceiling of that integer type, every new write stops.
Data imports and math inside queries can also push values past the allowed range. Multiplying two columns in an update statement can create a huge result very fast. If the target column is too small for the answer, the engine rejects it.
How to diagnose and fix out of range values safely
Start by reading the full error log to find the exact column and row. The message names the broken column and gives the row number from your batch. Next, inspect the table schema to see the current data type and sign setting. Compare those column limits against the raw payload that your app or script sent.
DPoP (Demonstration of Proof-of-Possession) + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Do not turn off strict SQL mode to make this error go away. Turning off strict rules tells the engine to clip numbers and write bad data. Financial totals, counters, and foreign keys break when the database changes numbers on write. Keep strict rules active so bad writes fail before they corrupt your production tables.
If the input number is wrong, fix the bug inside your app code first. Add input checks to block negative numbers or huge values before sending the query. Sometimes an upstream service sends a millisecond timestamp when the table expects seconds. Fixing the unit conversion in the app solves the issue without touching the database.
If the large number is valid, alter the column to a bigger data type. Move small integers up to standard integers, or step standard integers up to bigints. For decimal fields, raise the total digit count while keeping the same decimal places. Run schema changes with an online tool so production traffic does not lock up.
How to prevent column overflow in production
Track auto increment usage across all tables as part of your weekly health checks. Query the system catalog to compare the highest stored ID against the column limit. Set an alert when any key column passes seventy percent of its max capacity. This gives your team plenty of time to plan a safe type change.
Use unsigned types for ID columns and counters that never need negative values. This simple choice doubles the room in the column without using extra disk space. When you design new tables, pick big integers for tables that log events fast. Review schema changes in code review to catch small number types before launch.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.
With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
What does SQLSTATE 22003 mean in MySQL?
SQLSTATE 22003 is the standard code for a numeric value out of range. It pairs with error 1264 when a number is too big or too small.
Why does a negative number trigger error 1264?
A column marked as unsigned can only store zero and positive numbers. Sending any negative value falls below zero and triggers an out of range failure.
Should I disable strict mode to stop error 1264?
No, disabling strict mode causes the engine to clip your numbers to fit. You lose the real value and end up with silent data corruption in production.
Related guides
In this post