Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, but...

在使用Python 3.6进行MySQL数据库建表时,遇到关于'utf8'字符集的警告信息,解释了该警告的原因及解决方案。指出MySQL中的'utf8'实际上仅支持UTF8MB3,而非完整的UTF-8标准,建议使用'UTF8MB4'以避免未来数据存储上的潜在问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用Python3.6建表的时候遇到的一个警告

Warning: (3719, “‘utf8’ is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.”)
result = self._query(query)

这个警告还是蛮重要的,虽然不影响建表,但如果忽视可能会后续数据存储上引发问题,在一开始解决比较好。

MySQL中的所谓的utf8实际上并不是真正的UTF-8,它只支持每个字符最多三个字节UTF8MB3,而真正的UTF-8每个字符最多支持四个字节。

MySQL的解决这个问题的方法是直接发布了一个“UTF8MB4”的字符集,这个就是真正的UTF-8。

所以我们以后要想设置UTF-8时,直接用UTF8MB4即可,不要用utf8。

2025-03-16T04:48:11.723920Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start. 2025-03-16T04:48:11.741228Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2025-03-16T04:48:11.742158Z 0 [System] [MY-013169] [Server] D:\Mysql\bin\mysqld.exe (mysqld 9.2.0) initializing of server in progress as process 9208 2025-03-16T04:48:11.768998Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2025-03-16T04:48:11.818749Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2025-03-16T04:48:12.039225Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2025-03-16T04:48:13.332983Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fIIrem7oIb.& 2025-03-16T04:48:14.410749Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end. 2025-03-16T04:55:44.566160Z 0 [System] [MY-015015] [Server] MySQL Server - start. 2025-03-16T04:55:44.650933Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2025-03-16T04:55:44.651190Z 0 [System] [MY-010116] [Server] D:\Mysql\bin\mysqld (mysqld 9.2.0) starting as process 27044 2025-03-16T04:55:44.653855Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2025-03-16T04:55:44.703565Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2025-03-16T04:55:44.951140Z 1 [System] [MY-013577] [InnoDB] InnoDB initiali
03-17
2025-03-30T05:26:36.630970Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start. 2025-03-30T05:26:36.651088Z 0 [Warning] [MY-010915] [Server] &#39;NO_ZERO_DATE&#39;, &#39;NO_ZERO_IN_DATE&#39; and &#39;ERROR_FOR_DIVISION_BY_ZERO&#39; sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2025-03-30T05:26:36.651348Z 0 [System] [MY-013169] [Server] F:\mysql-9.2.0-winx64\bin\mysqld.exe (mysqld 9.2.0) initializing of server in progress as process 11812 2025-03-30T05:26:36.654113Z 0 [Warning] [MY-013242] [Server] --character-set-server: &#39;utf8&#39; is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2025-03-30T05:26:36.689720Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2025-03-30T05:26:36.981563Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2025-03-30T05:26:38.209156Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =ogq_<5aWuN( 2025-03-30T05:26:39.376516Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end. 2025-03-30T05:26:52.723152Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start. 2025-03-30T05:26:52.728735Z 0 [Warning] [MY-010915] [Server] &#39;NO_ZERO_DATE&#39;, &#39;NO_ZERO_IN_DATE&#39; and &#39;ERROR_FOR_DIVISION_BY_ZERO&#39; sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2025-03-30T05:26:52.728954Z 0 [System] [MY-013169] [Server] F:\mysql-9.2.0-winx64\bin\mysqld.exe (mysqld 9.2.0) initializing of server in progress as process 4424 2025-03-30T05:26:52.730538Z 0 [Warning] [MY-013242] [Server] --character-set-server: &#39;utf8&#39; is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2025-03-30T05:26:52.730695Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data dire
最新发布
03-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值