mysql - Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=' - Stack Overflow
mysql - Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=' - Stack Overflow
operation '='
Asked 12 years, 8 months ago Modified 2 months ago Viewed 383k times
I have gone through several other posts and was not able to solve this problem. The part affected is something similar to this:
I was testing with php, but the same error is given with SQLyog. I have also tested recreating the entire DB but to no good.
mysql stored-procedures
Share Improve this question Follow edited Feb 21, 2019 at 13:16 asked Aug 2, 2012 at 2:05
agold Manatax
6,286 9 40 54 4,233 6 31 41
1 I have faced the same issue when try to join records of 3 tables. When I checked my database, I found that, one of the table has utf8_general but other are have
utf8_unicode_ci. So I changed utf8_general to utf8_unicode_ci and my problem solved. – rahim.nagori Oct 28, 2020 at 10:28
Unless you need to sort data in Unicode order, I would suggest altering all your tables to use utf8_general_ci collation, as it requires no code
changes, and will speed sorts up slightly.
UPDATE: utf8mb4/utf8mb4_unicode_ci is now the preferred character set/collation method. utf8_general_ci is advised against, as the performance
improvement is negligible. See https://stackoverflow.com/a/766996/1432614
Share Improve this answer Follow edited Jun 15, 2021 at 14:41 answered Aug 2, 2012 at 2:25
Ross Smith II
12.2k 1 40 45
2 It is also possible to add COLLATE utf8_unicode_ci to string constants: SET @EMAIL = '[email protected]' COLLATE utf8_unicode_ci; . It is especially useful if you
are running a script from a console, where the console default encoding applies to your string constants' collation. – gaborsch May 5, 2016 at 10:35
Or drop database and create new with utf8_general_ci; collation. – Oleksii Kyslytsyn Apr 1, 2017 at 22:05
4 For future reference, don't change all your tables to utf8_general_ci unless you understand the differences between the two collations. – Manatax Jul 31, 2017 at 19:10
2 @GaborSch Adding collate to string variables was the solution for me, I wrote a detailed answer about it before I noticed your comment. – nkatsar Oct 10, 2017 at 16:49
im getting the same error, except (utf8mb4_unicode_ci, IMPLICIT) instead of (utf8_unicode_ci, IMPLICIT) . i am scraping data off the web using python, then
creating an CSV file with the scraped data, which i then process with a PHP file on my server that uploads the data to my database. all my MySQL tables/columns are
collated as utf8mb4_unicode_ci . might the issue be arising because i encode the data as utf8 in python/csv? – oldboy Nov 7, 2018 at 8:29
It seems option 4 won't work, you have to specify collation for each column, not only for the table (at least when the table already exists). – Skippy le Grand Gourou Aug
23, 2019 at 8:17
unfortunately, collate can't be added to the IN parameters in mysql 5.7 – veritas Jun 15, 2021 at 8:48
I got this 'Error Code: 1253. COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'utf8mb4' ' – Saige Zhang Dec 4, 2023 at 22:52