Warning
Error Code:
3720
MySQL Error 3720: National Character Set UTF8MB3 Deprecation
Description
MySQL Error 3720 is a warning indicating that the use of `NATIONAL`, `NCHAR`, or `NVARCHAR` data types currently implies the `UTF8MB3` character set. This implicit mapping is scheduled to change to `UTF8MB4` in a future MySQL release. The error prompts users to explicitly define `UTF8MB4` for clarity and future compatibility.
Error Message
NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Known Causes
3 known causesImplicit Character Set Usage
Using `NATIONAL`, `NCHAR`, or `NVARCHAR` without explicitly specifying a character set, causing MySQL to default to `UTF8MB3`.
Reliance on Deprecated Default
Your database schema or application logic relies on the current default behavior where national string types map to `UTF8MB3`, which is being deprecated.
Future Compatibility Planning
This warning is a proactive alert from MySQL about a planned change in future versions regarding the default character set for national string data types.
Solutions
4 solutions available1. Update `NATIONAL` to `UTF8MB4` in Schema Definitions easy
Directly replace `NATIONAL` with `CHARACTER SET UTF8MB4` in your table definitions.
1
Identify all occurrences of `NATIONAL` in your `CREATE TABLE` or `ALTER TABLE` statements. This often applies to `NCHAR` and `NVARCHAR` data types.
Example of problematic schema:
CREATE TABLE users (
id INT PRIMARY KEY,
name NATIONAL VARCHAR(255)
);
2
Modify your schema definitions to explicitly use `CHARACTER SET UTF8MB4` for these columns.
Example of corrected schema:
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(255) CHARACTER SET UTF8MB4
);
3
Apply the updated schema definitions to your database. For existing tables, you'll need to use `ALTER TABLE` statements.
ALTER TABLE your_table_name MODIFY column_name VARCHAR(255) CHARACTER SET UTF8MB4;
2. Use `utf8mb4` Directly in Data Type Declarations easy
Replace `NATIONAL` keywords with explicit `CHARACTER SET utf8mb4` during table creation or alteration.
1
When creating new tables, instead of relying on the implicit `NATIONAL` behavior, specify the character set directly.
CREATE TABLE products (
id INT PRIMARY KEY,
description VARCHAR(1000) CHARACTER SET utf8mb4
);
2
For existing tables, use `ALTER TABLE` to modify columns that were implicitly using `NATIONAL` to explicitly use `utf8mb4`.
ALTER TABLE customers
MODIFY email VARCHAR(255) CHARACTER SET utf8mb4;
3. Configure MySQL Server Defaults to `utf8mb4` medium
Set the server's default character set to `utf8mb4` to avoid implicit `utf8mb3` usage.
1
Locate your MySQL configuration file (e.g., `my.cnf` or `my.ini`). The location varies by operating system.
On Linux/macOS: `/etc/my.cnf`, `/etc/mysql/my.cnf`, or in `/etc/mysql/conf.d/`
On Windows: `my.ini` in the MySQL installation directory.
2
Add or modify the `character-set-server` and `collation-server` settings under the `[mysqld]` section to `utf8mb4` and `utf8mb4_unicode_ci` respectively.
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
3
Restart the MySQL server for the changes to take effect.
On Linux (systemd):
sudo systemctl restart mysql
On Linux (SysVinit):
sudo service mysql restart
On Windows:
Open Services (services.msc), find your MySQL service, and restart it.
4
After restarting, verify the server's default character set.
SHOW VARIABLES LIKE 'character_set_server';
SHOW VARIABLES LIKE 'collation_server';
4. Scripted Schema Migration advanced
Automate the process of finding and converting `NATIONAL` columns across your database.
1
Query the `information_schema.COLUMNS` table to identify columns that are using `NATIONAL` (which implicitly uses `utf8mb3`).
SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
COLUMN_TYPE
FROM
information_schema.COLUMNS
WHERE
CHARACTER_SET_NAME = 'utf8mb3'
AND COLUMN_TYPE LIKE '%NATIONAL%'
OR COLUMN_TYPE LIKE '%NCHAR%'
OR COLUMN_TYPE LIKE '%NVARCHAR%';
2
Generate `ALTER TABLE` statements to change these columns to use `VARCHAR` with `CHARACTER SET utf8mb4`.
SELECT
CONCAT('ALTER TABLE `', TABLE_SCHEMA, '`.`', TABLE_NAME, '` MODIFY `', COLUMN_NAME, '` ', COLUMN_TYPE, ' CHARACTER SET utf8mb4;')
FROM
information_schema.COLUMNS
WHERE
CHARACTER_SET_NAME = 'utf8mb3'
AND COLUMN_TYPE LIKE '%NATIONAL%'
OR COLUMN_TYPE LIKE '%NCHAR%'
OR COLUMN_TYPE LIKE '%NVARCHAR%';
3
Review the generated SQL statements carefully. It's highly recommended to test these on a staging or development environment first.
The output from the previous step will be a list of SQL commands.
4
Execute the generated `ALTER TABLE` statements on your production database. Ensure you have a proper backup before proceeding.
Execute the SQL output from the previous step.