【问题标题】:Procedure in mysqldb fails Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operation 'like'mysqldb 中的过程失败 非法混合排序规则 (utf8mb4_general_ci,IMPLICIT) 和 (utf8mb4_unicode_ci,IMPLICIT) 用于操作“like”
【发布时间】:2020-11-11 18:57:32
【问题描述】:

我正在mysql中运行该过程,但由于以下错误而失败

错误 1267 (HY000):排序规则 (utf8mb4_general_ci,IMPLICIT) 和 (utf8mb4_unicode_ci,IMPLICIT) 用于操作“like”的非法混合

mysql> show PROCEDURE STATUS where name like 'PRE_PROCESSING';

+-----------------+----------------+-----------+-------------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |
+-----------------+----------------+-----------+-------------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| main_model | PRE_PROCESSING | PROCEDURE | main_model@% | 2020-09-18 20:30:18 | 2020-09-18 20:30:18 | DEFINER | | utf8mb4 | utf8mb4_general_ci | utf8mb4_unicode_ci |
+-----------------+----------------+-----------+-------------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
    
mysql> show TABLE STATUS where name like 'Customer'; +-----------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ | Name      | Engine | Version | Row_format | Rows  | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation          | Checksum | Create_options | Comment | +-----------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ | Customer | InnoDB |      10 | Dynamic    | 14174 |            338 |     4800512 |               0 |      3735552 |   2097152 |           NULL | 2020-09-18 20:30:17 | NULL        | NULL       | utf8mb4_unicode_ci |     NULL |                |         | +-----------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ 1 row in set (0.00 sec)
    
show variables like "%collation%";
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+----------------------+--------------------+

【问题讨论】:

  • 我会使用明确的排序规则指定。显示导致问题的语句。
  • 请显示show create procedure PRE_PROCESSING \Gshow create table Customer \G 的输出以及您发出的导致错误的请求。

标签: mysql collation


【解决方案1】:
DROP PROCEDURE ...
SET NAMES ...
CREATE PROCEDURE ...

也就是说,将程序更改为使用所需的字符集和COLLATION

如果失败,请查看 Troubleshooting "Illegal mix of collations" error in mysql ,之前链接为“重复”。

【讨论】:

    猜你喜欢
    • 2017-10-17
    • 2016-08-18
    • 1970-01-01
    • 2021-05-06
    • 1970-01-01
    • 2021-04-13
    • 2010-11-03
    • 2012-07-30
    • 1970-01-01
    相关资源
    最近更新 更多