我有一个整理问题。它影响了该表的 3 列,creation_date、product_id 和 lastmodified。
我已将列更改为 utf8mb4 但他们不接受。请看下文。
CREATE TABLE `users` (
`id` int(32) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`creation_date` datetime DEFAULT NULL,
`product_id` int(32) DEFAULT NULL,
`lastmodified` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=121 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
查询:
select * from users u where u.name like '%philėp%'
No errors, 1 row.
select * from users u where u.creation_date like '%philėp%'
Illegal mix of collations for operation 'like'
MySQL系统变量:
show variables like '%character_set%';
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8mb4
character_set_system utf8
当我手动强制 MySQL 转换语句中的列时,它确实有效。
select * from users u where CONVERT(u.creation_date USING utf8mb4) like '%philėp%'
No errors; 0 rows;
它不是utf8mb4格式了吗?
将不胜感激任何帮助。