Warning 1681: integer display width is deprecated
Warning: #1681 Integer display width is deprecated and will be removed in a future release.Short answer
Warning 1681 is not an error and the table is created. MySQL deprecated the display width in types such as INT(11), and ZEROFILL with it. The width never limited the values a column can hold. Remove the number from the type, and use LPAD() where you needed zero-padded output.
Fix it fast
1Find out which cause you have
Read the full warning list after the statement that triggered it. It names what is deprecated, and the table definition shows which columns carry a width.
SHOW WARNINGS; SHOW CREATE TABLE orders\G2Match what you see, then jump to its fix
What does the error look like?
Warning: #1681 Integer display width is deprecated and will be removed in a future release.
Cause 1 of 2
A column is declared with a display width such as INT(11)
1Check
Find the columns that have a number in brackets after an integer type, in your schema file, migration or dump.
SHOW CREATE TABLE orders\G
-- look for int(11), bigint(20), smallint(5)2Fix
Remove the number. The manual states that the display width does not constrain the range of values the column stores, so nothing about the data changes.
-- before
CREATE TABLE orders (id INT(11) NOT NULL, qty SMALLINT(5) NOT NULL);
-- after
CREATE TABLE orders (id INT NOT NULL, qty SMALLINT NOT NULL);3Verify
Run the statement again. SHOW WARNINGS returns nothing for these columns.
SHOW WARNINGS;Confirmed by dev.mysql.com
Cause 2 of 2
ZEROFILL is used to pad numbers
1Check
ZEROFILL is deprecated together with the display width. It also adds UNSIGNED automatically, and it is ignored in expressions and UNION queries.
SHOW CREATE TABLE tickets\G2Fix
Store the plain integer and pad it when you read it, with LPAD(), or keep the formatted number in a CHAR column.
ALTER TABLE tickets MODIFY number INT UNSIGNED NOT NULL;
SELECT LPAD(number, 4, '0') AS ticket_no FROM tickets;3Verify
The query returns 0005 for the value 5 and the warning is gone.
SELECT LPAD(5, 4, '0');Confirmed by dev.mysql.com
How do I stop it coming back?
- Write integer columns without a number, for example INT or BIGINT, in new schemas and migrations.
- Do the zero padding in the query or in the application, not in the column type.
- Check SHOW WARNINGS after schema changes so deprecations show up before they become errors.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver fails to resolve Maven dependencies when downloading a database driver
A driver library does not download automatically
DBeaver downloads driver jars from a Maven repository.
3 causes, each with a fixDatabases
DBeaver cannot verify the MySQL server certificate
unable to find valid certification path to requested target
DBeaver's MySQL driver is checking the server certificate and Java does not trust the CA that signed it.
2 causes, each with a fix