0

I have a collation error with MySQL, specifically it is the following:

OperationalError: (1267, "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")

After checking, I noticed that it is related to certain emojis, mostly smileys. I've checked my MySQL database and it is by default using utf8mb4 charset as shown:

+------------+---------------------------------------------------------------------------------------------------+
| Database   | Create Database                                                                                   |
+------------+---------------------------------------------------------------------------------------------------+
| Dictionary | CREATE DATABASE `Dictionary` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ |
+------------+---------------------------------------------------------------------------------------------------+

My MySQL settings also indicate that everything needed is set to utf8mb4:

+--------------------------+--------------------+
| Variable_name            | Value              |
+--------------------------+--------------------+
| character_set_client     | utf8mb4            |
| character_set_connection | utf8mb4            |
| character_set_database   | utf8mb4            |
| character_set_filesystem | binary             |
| character_set_results    | utf8mb4            |
| character_set_server     | utf8mb4            |
| character_set_system     | utf8               |
| collation_connection     | utf8mb4_unicode_ci |
| collation_database       | utf8mb4_unicode_ci |
| collation_server         | utf8mb4_unicode_ci |
+--------------------------+--------------------+

I am using Peewee (the Python module) to make my queries and the following line is the one that is causing the collation error

SingleWords.get(SingleWords.word == lowercase)

It is not much of a problem for me if I can't insert certain emojis, but I would still like to if possible. I have no idea why this is happening, any thoughts?

4

1 回答 1

0

尝试这个

  SELECT * COLLATE latin1_general_ci FROM table;

这将使用 collat​​e latin1_general_ci 选择所有

于 2014-02-21T11:48:18.033 回答