微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

由于隐式排序规则,更新语句在 mysql 8.0 中失败

如何解决由于隐式排序规则,更新语句在 mysql 8.0 中失败

对于所有类型的更新操作都出现此 MysqL 错误

update `servershopcategories` set category_icon_path = 'veLocity/category_icon_path/2/D02nx6aqc85HngSy6QC9LdWKtABuDFGb7fNQenuG.png',`servershopcategories`.`updated_at` = '2021-06-22 00:08:05' where `id` = 2;
ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='

这是我的表配置的样子

MysqL> SHOW TABLE STATUS where name like 'servershopcategories' \G;
*************************** 1. row ***************************
           Name: servershopcategories
         Engine: InnoDB
        Version: 10
     Row_format: Dynamic
           Rows: 2
 Avg_row_length: 8192
    Data_length: 16384
Max_data_length: 0
   Index_length: 16384
      Data_free: 0
 Auto_increment: 3
    Create_time: 2021-06-22 00:29:05
    Update_time: 2021-06-21 04:01:49
     Check_time: NULL
      Collation: utf8mb4_unicode_ci
       Checksum: NULL
 Create_options: row_format=DYNAMIC
        Comment: 
1 row in set (0.01 sec)

这是表结构

MysqL> show full columns from servershopcategories;                                                                                                                                                           
+--------------------+--------------+--------------------+------+-----+--------------------------+----------------+---------------------------------+---------+
| Field              | Type         | Collation          | Null | Key | Default                  | Extra          | Privileges                      | Comment |
+--------------------+--------------+--------------------+------+-----+--------------------------+----------------+---------------------------------+---------+
| id                 | int unsigned | NULL               | NO   | PRI | NULL                     | auto_increment | select,insert,update,references |         |
| position           | int          | NULL               | NO   |     | 0                        |                | select,references |         |
| image              | varchar(191) | utf8mb4_unicode_ci | YES  |     | NULL                     |                | select,references |         |
| status             | tinyint(1)   | NULL               | NO   |     | 0                        |                | select,references |         |
| _lft               | int unsigned | NULL               | NO   | MUL | 0                        |                | select,references |         |
| _rgt               | int unsigned | NULL               | NO   |     | 0                        |                | select,references |         |
| parent_id          | int unsigned | NULL               | YES  |     | NULL                     |                | select,references |         |
| created_at         | timestamp    | NULL               | YES  |     | NULL                     |                | select,references |         |
| updated_at         | timestamp    | NULL               | YES  |     | NULL                     |                | select,references |         |
| display_mode       | varchar(191) | utf8mb4_unicode_ci | YES  |     | products_and_description |                | select,references |         |
| category_icon_path | varchar(500) | utf8mb4_unicode_ci | YES  |     | NULL                     |                | select,references |         |
| additional         | json         | NULL               | YES  |     | NULL                     |                | select,references |         |
+--------------------+--------------+--------------------+------+-----+--------------------------+----------------+---------------------------------+---------+

首先,我认为我在 set 操作中给出的字符串有问题,但令人惊讶的是,即使更简单的更新操作也会失败,例如

MysqL> update servershopcategories set position = 2 where id = 2;
ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) for operation '='

我尝试了很多,从这里和那里更改排序规则,但我觉得这里缺少一些东西。我在网上搜索了多种解决方案,但似乎都不起作用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。