mysql Ver 8.0.25
Got this error in apache log:
Error query: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' In query: SELECT
idaction
,type
,name
FROM matomo_log_action WHERE ( hash = CRC32(?) AND name = ? AND type = ? ) [...]
This is the table's info:
mysql> SHOW FULL COLUMNS FROM matomo_log_action;
+------------+------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+------------+------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
| idaction | int unsigned | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
| name | varchar(4096) | utf8mb4_unicode_ci | YES | | NULL | | select,insert,update,references | |
| hash | int unsigned | NULL | NO | | NULL | | select,insert,update,references | |
| type | tinyint unsigned | NULL | YES | MUL | NULL | | select,insert,update,references | |
| url_prefix | tinyint | NULL | YES | | NULL | | select,insert,update,references | |
+------------+------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
Now I think I need to modify the Collation
of field type
to utf8mb4_unicode_ci
, but don't know how:
mysql> ALTER TABLE matomo_log_action MODIFY type tinyint unsigned CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci' at line 1
type
is numeric, and charset/collation is not applicable to it. Now I think I need to modify the Collation of field type to utf8mb4_unicode_ci ?? Why do you think so? The error message shows that you'd modify the columnname
.name
is critical, modify the string literal which is provided as query parameter. Like.. AND name = ? COLLATE utf8mb4_unicode_ci AND ..