Ошибка illegal mix of collations

Am getting the below error when trying to do a select through a stored procedure in MySQL.

Illegal mix of collations (latin1_general_cs,IMPLICIT) and (latin1_general_ci,IMPLICIT) for operation ‘=’

Any idea on what might be going wrong here?

The collation of the table is latin1_general_ci and that of the column in the where clause is latin1_general_cs.

asked Jun 12, 2010 at 16:23

user355562's user avatar

2

This is generally caused by comparing two strings of incompatible collation or by attempting to select data of different collation into a combined column.

The clause COLLATE allows you to specify the collation used in the query.

For example, the following WHERE clause will always give the error you posted:

WHERE 'A' COLLATE latin1_general_ci = 'A' COLLATE latin1_general_cs

Your solution is to specify a shared collation for the two columns within the query. Here is an example that uses the COLLATE clause:

SELECT * FROM table ORDER BY key COLLATE latin1_general_ci;

Another option is to use the BINARY operator:

BINARY str is the shorthand for CAST(str AS BINARY).

Your solution might look something like this:

SELECT * FROM table WHERE BINARY a = BINARY b;

or,

SELECT * FROM table ORDER BY BINARY a;

Please keep in mind that, as pointed out by Jacob Stamm in the comments, «casting columns to compare them will cause any indexing on that column to be ignored».

For much greater detail about this collation business, I highly recommend eggyal’s excellent answer to this same question.

answered Jun 12, 2010 at 17:17

defines's user avatar

definesdefines

10.2k4 gold badges40 silver badges55 bronze badges

6

TL;DR

Either change the collation of one (or both) of the strings so that they match, or else add a COLLATE clause to your expression.


  1. What is this «collation» stuff anyway?

    As documented under Character Sets and Collations in General:

    A character set is a set of symbols and encodings. A collation is a set of rules for comparing characters in a character set. Let’s make the distinction clear with an example of an imaginary character set.

    Suppose that we have an alphabet with four letters: “A”, “B”, “a”, “b”. We give each letter a number: “A” = 0, “B” = 1, “a” = 2, “b” = 3. The letter “A” is a symbol, the number 0 is the encoding for “A”, and the combination of all four letters and their encodings is a character set.

    Suppose that we want to compare two string values, “A” and “B”. The simplest way to do this is to look at the encodings: 0 for “A” and 1 for “B”. Because 0 is less than 1, we say “A” is less than “B”. What we’ve just done is apply a collation to our character set. The collation is a set of rules (only one rule in this case): “compare the encodings.” We call this simplest of all possible collations a binary collation.

    But what if we want to say that the lowercase and uppercase letters are equivalent? Then we would have at least two rules: (1) treat the lowercase letters “a” and “b” as equivalent to “A” and “B”; (2) then compare the encodings. We call this a case-insensitive collation. It is a little more complex than a binary collation.

    In real life, most character sets have many characters: not just “A” and “B” but whole alphabets, sometimes multiple alphabets or eastern writing systems with thousands of characters, along with many special symbols and punctuation marks. Also in real life, most collations have many rules, not just for whether to distinguish lettercase, but also for whether to distinguish accents (an “accent” is a mark attached to a character as in German “Ö”), and for multiple-character mappings (such as the rule that “Ö” = “OE” in one of the two German collations).

    Further examples are given under Examples of the Effect of Collation.

  2. Okay, but how does MySQL decide which collation to use for a given expression?

    As documented under Collation of Expressions:

    In the great majority of statements, it is obvious what collation MySQL uses to resolve a comparison operation. For example, in the following cases, it should be clear that the collation is the collation of column charset_name:

    SELECT x FROM T ORDER BY x;
    SELECT x FROM T WHERE x = x;
    SELECT DISTINCT x FROM T;
    

    However, with multiple operands, there can be ambiguity. For example:

    SELECT x FROM T WHERE x = 'Y';
    

    Should the comparison use the collation of the column x, or of the string literal 'Y'? Both x and 'Y' have collations, so which collation takes precedence?

    Standard SQL resolves such questions using what used to be called “coercibility” rules.

    [ deletia ]

    MySQL uses coercibility values with the following rules to resolve ambiguities:

    • Use the collation with the lowest coercibility value.

    • If both sides have the same coercibility, then:

      • If both sides are Unicode, or both sides are not Unicode, it is an error.

      • If one of the sides has a Unicode character set, and another side has a non-Unicode character set, the side with Unicode character set wins, and automatic character set conversion is applied to the non-Unicode side. For example, the following statement does not return an error:

        SELECT CONCAT(utf8_column, latin1_column) FROM t1;
        

        It returns a result that has a character set of utf8 and the same collation as utf8_column. Values of latin1_column are automatically converted to utf8 before concatenating.

      • For an operation with operands from the same character set but that mix a _bin collation and a _ci or _cs collation, the _bin collation is used. This is similar to how operations that mix nonbinary and binary strings evaluate the operands as binary strings, except that it is for collations rather than data types.

  3. So what is an «illegal mix of collations»?

    An «illegal mix of collations» occurs when an expression compares two strings of different collations but of equal coercibility and the coercibility rules cannot help to resolve the conflict. It is the situation described under the third bullet-point in the above quotation.

    The particular error given in the question, Illegal mix of collations (latin1_general_cs,IMPLICIT) and (latin1_general_ci,IMPLICIT) for operation '=', tells us that there was an equality comparison between two non-Unicode strings of equal coercibility. It furthermore tells us that the collations were not given explicitly in the statement but rather were implied from the strings’ sources (such as column metadata).

  4. That’s all very well, but how does one resolve such errors?

    As the manual extracts quoted above suggest, this problem can be resolved in a number of ways, of which two are sensible and to be recommended:

    • Change the collation of one (or both) of the strings so that they match and there is no longer any ambiguity.

      How this can be done depends upon from where the string has come: Literal expressions take the collation specified in the collation_connection system variable; values from tables take the collation specified in their column metadata.

    • Force one string to not be coercible.

      I omitted the following quote from the above:

      MySQL assigns coercibility values as follows:

      • An explicit COLLATE clause has a coercibility of 0. (Not coercible at all.)

      • The concatenation of two strings with different collations has a coercibility of 1.

      • The collation of a column or a stored routine parameter or local variable has a coercibility of 2.

      • A “system constant” (the string returned by functions such as USER() or VERSION()) has a coercibility of 3.

      • The collation of a literal has a coercibility of 4.

      • NULL or an expression that is derived from NULL has a coercibility of 5.

      Thus simply adding a COLLATE clause to one of the strings used in the comparison will force use of that collation.

    Whilst the others would be terribly bad practice if they were deployed merely to resolve this error:

    • Force one (or both) of the strings to have some other coercibility value so that one takes precedence.

      Use of CONCAT() or CONCAT_WS() would result in a string with a coercibility of 1; and (if in a stored routine) use of parameters/local variables would result in strings with a coercibility of 2.

    • Change the encodings of one (or both) of the strings so that one is Unicode and the other is not.

      This could be done via transcoding with CONVERT(expr USING transcoding_name); or via changing the underlying character set of the data (e.g. modifying the column, changing character_set_connection for literal values, or sending them from the client in a different encoding and changing character_set_client / adding a character set introducer). Note that changing encoding will lead to other problems if some desired characters cannot be encoded in the new character set.

    • Change the encodings of one (or both) of the strings so that they are both the same and change one string to use the relevant _bin collation.

      Methods for changing encodings and collations have been detailed above. This approach would be of little use if one actually needs to apply more advanced collation rules than are offered by the _bin collation.

answered Jan 11, 2014 at 10:45

eggyal's user avatar

eggyaleggyal

122k18 gold badges210 silver badges236 bronze badges

5

Adding my 2c to the discussion for future googlers.

I was investigating a similar issue where I got the following error when using custom functions that recieved a varchar parameter:

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and 
(utf8_general_ci,IMPLICIT) for operation '='

Using the following query:

mysql> show variables like "collation_database";
    +--------------------+-----------------+
    | Variable_name      | Value           |
    +--------------------+-----------------+
    | collation_database | utf8_general_ci |
    +--------------------+-----------------+

I was able to tell that the DB was using utf8_general_ci, while the tables were defined using utf8_unicode_ci:

mysql> show table status;
    +--------------+-----------------+
    | Name         | Collation       |
    +--------------+-----------------+
    | my_view      | NULL            |
    | my_table     | utf8_unicode_ci |
    ...

Notice that the views have NULL collation. It appears that views and functions have collation definitions even though this query shows null for one view. The collation used is the DB collation that was defined when the view/function were created.

The sad solution was to both change the db collation and recreate the views/functions to force them to use the current collation.

  • Changing the db’s collation:

    ALTER DATABASE mydb DEFAULT COLLATE utf8_unicode_ci;
    
  • Changing the table collation:

    ALTER TABLE mydb CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    

I hope this will help someone.

Mladen Janjetovic's user avatar

answered Jun 24, 2012 at 16:56

Ariel T's user avatar

Ariel TAriel T

2,8591 gold badge20 silver badges21 bronze badges

7

Sometimes it can be dangerous to convert charsets, specially on databases with huge amounts of data. I think the best option is to use the «binary» operator:

e.g : WHERE binary table1.column1 = binary table2.column1

Marlon Bernardes's user avatar

answered Nov 24, 2012 at 10:36

Justin Vincent's user avatar

2

I had a similar problem, was trying to use the FIND_IN_SET procedure with a string variable.

SET @my_var = 'string1,string2';
SELECT * from my_table WHERE FIND_IN_SET(column_name,@my_var);

and was receiving the error

Error Code: 1267. Illegal mix of collations (utf8_unicode_ci,IMPLICIT)
and (utf8_general_ci,IMPLICIT) for operation ‘find_in_set’

Short answer:

No need to change any collation_YYYY variables, just add the correct collation next to your variable declaration, i.e.

SET @my_var = 'string1,string2' COLLATE utf8_unicode_ci;
SELECT * from my_table WHERE FIND_IN_SET(column_name,@my_var);

Long answer:

I first checked the collation variables:

mysql> SHOW VARIABLES LIKE 'collation%';
    +----------------------+-----------------+
    | Variable_name        | Value           |
    +----------------------+-----------------+
    | collation_connection | utf8_general_ci |
    +----------------------+-----------------+
    | collation_database   | utf8_general_ci |
    +----------------------+-----------------+
    | collation_server     | utf8_general_ci |
    +----------------------+-----------------+

Then I checked the table collation:

mysql> SHOW CREATE TABLE my_table;

CREATE TABLE `my_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `column_name` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=125 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

This means that my variable was configured with the default collation of utf8_general_ci while my table was configured as utf8_unicode_ci.

By adding the COLLATE command next to the variable declaration, the variable collation matched the collation configured for the table.

answered Oct 10, 2017 at 16:39

nkatsar's user avatar

nkatsarnkatsar

1,57017 silver badges15 bronze badges

0

Below solution worked for me.

CONVERT( Table1.FromColumn USING utf8)    =  CONVERT(Table2.ToColumn USING utf8) 

answered Jul 9, 2020 at 8:26

garish's user avatar

garishgarish

62712 silver badges13 bronze badges

1

Solution if literals are involved.

I am using Pentaho Data Integration and dont get to specify the sql syntax.
Using a very simple DB lookup gave the error
«Illegal mix of collations (cp850_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation ‘='»

The generated code was
«SELECT DATA_DATE AS latest_DATA_DATE FROM hr_cc_normalised_data_date_v WHERE PSEUDO_KEY = ?»

Cutting the story short the lookup was to a view and when I issued

mysql> show full columns from hr_cc_normalised_data_date_v;
+------------+------------+-------------------+------+-----+
| Field      | Type       | Collation         | Null | Key |
+------------+------------+-------------------+------+-----+
| PSEUDO_KEY | varchar(1) | cp850_general_ci  | NO   |     |
| DATA_DATE  | varchar(8) | latin1_general_cs | YES  |     |
+------------+------------+-------------------+------+-----+

which explains where the ‘cp850_general_ci’ comes from.

The view was simply created with ‘SELECT ‘X’,……’
According to the manual literals like this should inherit their character set and collation from server settings which were correctly defined as ‘latin1’ and ‘latin1_general_cs’
as this clearly did not happen I forced it in the creation of the view

CREATE OR REPLACE VIEW hr_cc_normalised_data_date_v AS
SELECT convert('X' using latin1) COLLATE latin1_general_cs        AS PSEUDO_KEY
    ,  DATA_DATE
FROM HR_COSTCENTRE_NORMALISED_mV
LIMIT 1;

now it shows latin1_general_cs for both columns and the error has gone away. :)

answered Oct 20, 2015 at 2:58

jc508's user avatar

jc508jc508

915 bronze badges

If the columns that you are having trouble with are «hashes», then consider the following…

If the «hash» is a binary string, you should really use BINARY(...) datatype.

If the «hash» is a hex string, you do not need utf8, and should avoid such because of character checks, etc. For example, MySQL’s MD5(...) yields a fixed-length 32-byte hex string. SHA1(...) gives a 40-byte hex string. This could be stored into CHAR(32) CHARACTER SET ascii (or 40 for sha1).

Or, better yet, store UNHEX(MD5(...)) into BINARY(16). This cuts in half the size of the column. (It does, however, make it rather unprintable.) SELECT HEX(hash) ... if you want it readable.

Comparing two BINARY columns has no collation issues.

answered Dec 22, 2015 at 18:53

Rick James's user avatar

Rick JamesRick James

134k13 gold badges125 silver badges219 bronze badges

Very interesting… Now, be ready. I looked at all of the «add collate» solutions and to me, those are band aid fixes. The reality is the database design was «bad». Yes, standard changes and new things gets added, blah blah, but it does not change the bad database design fact. I refuse to go with the route of adding «collate» all over the SQL statements just to get my query to work. The only solution that works for me and will virtually eliminate the need to tweak my code in the future is to re-design the database/tables to match the character set that I will live with and embrace for the long term future. In this case, I choose to go with the character set «utf8mb4«.

So the solution here when you encounter that «illegal» error message is to re-design your database and tables. It is much easier and quicker then it sounds. Exporting your data and re-importing it from a CSV may not even be required. Change the character set of the database and make sure all the character set of your tables matches.

Use these commands to guide you:

SHOW VARIABLES LIKE "collation_database";
SHOW TABLE STATUS;

Now, if you enjoy adding «collate» here and there and beef up your code with forces fulls «overrides», be my guess.

answered Dec 25, 2019 at 22:15

CelestialEX's user avatar

MySQL really dislikes mixing collations unless it can coerce them to the same one (which clearly is not feasible in your case). Can’t you just force the same collation to be used via a COLLATE clause? (or the simpler BINARY shortcut if applicable…).

answered Jun 12, 2010 at 16:35

Alex Martelli's user avatar

Alex MartelliAlex Martelli

849k169 gold badges1218 silver badges1394 bronze badges

2

I used ALTER DATABASE mydb DEFAULT COLLATE utf8_unicode_ci;, but didn’t work.

In this query:

Select * from table1, table2 where table1.field = date_format(table2.field,'%H');

This work for me:

Select * from table1, table2 where concat(table1.field) = date_format(table2.field,'%H');

Yes, only a concat.

answered Dec 8, 2012 at 15:09

Knito Auron's user avatar

Knito AuronKnito Auron

4294 silver badges7 bronze badges

2

One another source of the issue with collations is mysql.proc table. Check collations of your storage procedures and functions:

SELECT
  p.db, p.db_collation, p.type, COUNT(*) cnt
FROM mysql.proc p
GROUP BY p.db, p.db_collation, p.type;

Also pay attention to mysql.proc.collation_connection and mysql.proc.character_set_client columns.

answered Sep 8, 2017 at 13:17

ruvim's user avatar

ruvimruvim

6,8762 gold badges24 silver badges35 bronze badges

I personnaly had this problem in a procedure.
If you dont want to alter table you can try to convert your parameter into the procedure .
I’ve try sevral use of collate (with a set into the select) but none works for me.

CONVERT(my_param USING utf32) did the trick.

answered Nov 16, 2020 at 9:42

blobmaster's user avatar

blobmasterblobmaster

8538 silver badges11 bronze badges

In my case the default return type of a function was the type/collation from database (utf8mb4_general_ci) but database column was ascii.

WHERE ascii_col = md5(concat_ws(',', a,b,c))

Quick fix was

WHERE ascii_col = BINARY md5(concat_ws(',', a,b,c))

answered Jan 21, 2022 at 9:09

Frank's user avatar

FrankFrank

1,88520 silver badges27 bronze badges

I compared fields from two databases. One uses utf8, the other utf8mb4. I noticed that only collating to utf8mb4 (I used utf8mb4_unicode_ci) worked. Trying utf8_unicode_ci produced an error.

To generalize: when comparing strings with different character sets it may be that only one of them works for the COLLATE command.

answered May 27 at 8:06

user2587656's user avatar

user2587656user2587656

3093 silver badges5 bronze badges

This code needs to be put inside Run SQL query/queries on database

SQL QUERY WINDOW

ALTER TABLE `table_name` CHANGE `column_name` `column_name`   VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;

Please replace table_name and column_name with appropriate name.

answered Oct 13, 2017 at 13:38

Sukumar's user avatar

SukumarSukumar

3193 silver badges10 bronze badges

Wondering how to resolve MySQL dump error ‘illegal mix of collations’? We can help you.

As part of our Server Management Services, we assist our customers with several MySQL queries.

Today, let us see how our Support Techs fix this error.

What causes MySQL dump error ‘illegal mix of collations’?

Typical error might look as shown below:

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

This error generally occurs by comparing two strings of incompatible collations or by attempting to select data of different collations into a combined column.

In this case, they are utf8_unicode_ci and utf8_general_ci.

Hence, we need to make the two columns collation match.

How to resolve it?

Let us see some of the steps followed by our Support Techs to resolve the issue.

1. Change the collation of one column (or string) to match the other collation.

Find the columns with inappropriate collation:

SHOW CREATE TABLE table_name;

So the chances are, you can find the column with a different collation or it hasn’t been specified at all.

Then, you can change the collation on each column:

ALTER TABLE table_name CHANGE col_name data_type CHARACTER SET charset_name COLLATE collation_name;

If you want to make a collation change table-wide:

ALTER TABLE table_name CONVERT TO CHARACTER SET charset_name COLLATE collation_name;

2. Add a COLLATE clause to specify the collation used in your query.

SELECT * FROM table _name ORDER BY col_name COLLATE collation_name;
3.Generate ALTER TABLE command into sql file and execute sql file on database. a.Generate ALTER TABLE command into sql file: SELECT CONCAT("alter table `", TABLE_SCHEMA,"`.`", TABLE_NAME, "` convert to character set utf8 collate utf8_general_ci;") as MySQLCMD
INTO OUTFILE "/var/tmp/test_schema_update.sql"
FROM information_schema.TABLES WHERE TABLE_SCHEMA = "test" The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax. file_name cannot be an existing file, which among other things prevents files such as /etc/passwd and database tables from being destroyed. As alternative if you are using Virtual machine or Docker container you could use client command such as mysql -e to generate file on local environment: mysql -h172.17.0.1 -uroot -e 'SELECT CONCAT("alter table `", TABLE_SCHEMA,"`.`", TABLE_NAME, "` convert to character set utf8 collate utf8_general_ci;") as MySQLCMD FROM information_schema.TABLES WHERE TABLE_SCHEMA = "test"' > /var/tmp/test_schema_update.sql b.

To execute generated file please use below command:

mysql -h172.17.0.1 -uroot dbname < /var/tmp/test_schema_update.sql

If you have got such error:

ERROR 1064 (42000) at line 1: 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 ‘MySQLCMD
alter table `dbname`.`tablename` convert to character set utf8 collate ‘ at line 1Just open test_schema_update.sql file and remove MySQLCMD string from the very beginning and save. After that try again to import file to your database.

Change the collation from command line.

Let us go through the steps followed by our Support techs to change the collation from command line.

  • Log into MySQL with SSH:
mysql -u admin -p`cat /etc/psa/.psa.shadow`
  • Enter your database password when prompted.
  • Run the following command to change the character set and collation of your database:
ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
  • Run the following command to change the character set and collation of your table:
ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;

For either of these examples, please replace the example character set and collation with your desired values.

[Finding it hard to fix MySQL error? We’d be happy to assist you]

Conclusion

In short, today we saw steps followed by our Support Techs to resolve this MySQL error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

SQL-ошибка: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation ‘=’
Возникает при попытке отправить комментарий на сайте.
База, все таблицы и поля у меня в кодировке utf8_general_ci
Пробовал записать это в базу через PMA и получил ошибку Warning: #1366 Incorrect string value: ‘xF0x9Fx8Fx86xF0x9F…’ for column
Содержимое комментария сюда тоже добавить не могу, символы теряются.
Прикрепил картинку: 5e089a4e82c0b487413650.png
Эти иконки в коде выглядят так: 5e089a87394c5822436593.png


  • Вопрос задан

    более трёх лет назад

  • 1952 просмотра

SET collation_connection = 'utf8mb4_general_ci';
ALTER DATABASE your_bd CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE your_table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Пригласить эксперта

Я думаю, причина в том, что «все таблицы и поля у меня в кодировке utf8_general_ci» — это в нектором роде фантазия, не совсем совпадающая с действительностью.

Ну и надо не забыть установить кодировку при соединении из пхп.


  • Показать ещё
    Загружается…

13 июн. 2023, в 15:10

25000 руб./за проект

13 июн. 2023, в 14:58

40000 руб./за проект

13 июн. 2023, в 14:45

3500 руб./за проект

Минуточку внимания

Столкнулся с проблемой несовпадения collations в БД. Интернет подобным просто кишит. Видал подобная проблема была озвучена на форумах, и был дан комплект SQL запросов напрямую к СУБД для её решения.

http://www.google.ru/search?q=SELECT+…utf-8&aq=t

У меня возникла ошибка вида

File: ... /bitrix/modules/search/classes/general/search.php
Line: 201
MySQL Query Error: SELECT sc.ID ,sc.MODULE_ID ,sc.IT...
[Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '=']

Вот шаблон к ее решению
1. Удаляем модуль поиск, включая таблицы и статистику.
2. Устанавливаем модуль вновь.

Подключаемся к СУБД с достаточными правами на модификацию таблиц в конкретной БД.
Я определил себе следующий пакет запросов

alter table b_search_content modify `SEARCHABLE_CONTENT` longtext NULL collate utf8_unicode_ci; 
alter table b_search_content modify `TITLE` text NULL collate utf8_unicode_ci; 
alter table b_search_content modify `TAGS` text NULL collate utf8_unicode_ci; 
alter table b_search_content modify `BODY` text NULL collate utf8_unicode_ci; 
alter table b_search_content modify `URL` text NULL collate utf8_unicode_ci; 
alter table b_search_content modify `PARAM1` text NULL collate utf8_unicode_ci; 
alter table b_search_content modify `PARAM2` text NULL collate utf8_unicode_ci; 
alter table b_search_content modify `LID` char(2) NOT NULL collate utf8_unicode_ci; 
alter table b_search_content modify `UPD` varchar(32) NULL collate utf8_unicode_ci; 
alter table b_search_content modify `ITEM_ID` varchar(255) NOT NULL collate utf8_unicode_ci; 

alter table b_search_content_site modify `SITE_ID` char(2) NOT NULL collate utf8_unicode_ci; 
alter table b_search_content_stem modify `LANGUAGE_ID` char(2) NOT NULL collate utf8_unicode_ci; 
alter table b_search_content_stem modify `STEM` varchar(50) NOT NULL collate utf8_unicode_ci; 
alter table b_lang modify `LID` char(2) NOT NULL collate utf8_unicode_ci; 

alter table b_search_tags modify `SITE_ID` char(2) NOT NULL collate utf8_unicode_ci; 
alter table b_search_content_freq modify `LANGUAGE_ID` char(2) NOT NULL collate utf8_unicode_ci; 
alter table b_search_content_freq modify `SITE_ID` char(2) NULL collate utf8_unicode_ci; 
alter table b_search_content_freq modify `STEM` varchar(50) NOT NULL collate utf8_unicode_ci; 

3. Проводим переиндексацию. Готово.

Группы на сайте создаются не только сотрудниками «1С-Битрикс», но и партнерами компании. Поэтому мнения участников групп могут не совпадать с позицией компании «1С-Битрикс».

The «Illegal mix of collations» error in MySQL occurs when you try to perform a query that mixes character sets or collations in an invalid way.

Here are some steps you can try to fix the «Illegal mix of collations» error:

  1. Make sure that all of the character sets and collations used in the query are compatible with each other. You can check the MySQL documentation for a list of compatible character sets and collations.
  2. If you are using string literals in your query, make sure that they are written using the correct character set and collation. You can specify the character set and collation for string literals using the _charset_name and _collation_name syntax, like this:

SELECT * FROM mytable WHERE name = 'John' COLLATE utf8_unicode_ci;

3. If you are using variables in your query, make sure that they have the correct character set and collation. You can set the character set and collation for variables using the SET statement, like this:

SET @name = 'John' COLLATE utf8_unicode_ci; SELECT * FROM mytable WHERE name = @name;

4. If the error persists, you may need to check the character set and collation of the columns in your tables. You can check the character set and collation of a column using the SHOW FULL COLUMNS FROM table_name query. If the character set and collation of the column do not match the ones used in the query, you can try changing the character set and collation of the column using the ALTER TABLE statement.

Common questions and answers about Mysql Illegal Mix Of Collations

Here are some common questions and answers about the «Illegal mix of collations» error in MySQL:

  1. What does the «Illegal mix of collations» error mean?The «Illegal mix of collations» error means that MySQL is unable to perform a query because it involves mixing character sets or collations in a way that is not allowed.
  2. What causes the «Illegal mix of collations» error?The «Illegal mix of collations» error can be caused by a number of factors, such as using incompatible character sets or collations in a query, using string literals with the wrong character set or collation, or using variables with the wrong character set or collation.
  3. How can I fix the «Illegal mix of collations» error?To fix the «Illegal mix of collations» error, you can try the following:
  • Make sure that all of the character sets and collations used in the query are compatible with each other.
  • Specify the character set and collation for string literals using the _charset_name and _collation_name syntax.
  • Set the character set and collation for variables using the SET statement.
  • Check the character set and collation of the columns in your tables, and change them if necessary using the ALTER TABLE statement.
  1. What should I do if the «Illegal mix of collations» error persists?If the «Illegal mix of collations» error persists after trying the above steps, you may need to do further troubleshooting. Some things you can try include checking the MySQL error log for more information, searching online for solutions specific to your setup, or seeking assistance from the MySQL support team or a technical expert.

I hope these suggestions are helpful! Let me know if you have any other questions.

Понравилась статья? Поделить с друзьями:
  • Ошибка i30 посудомоечной машины electrolux что это
  • Ошибка i20 в посудомоечной машине электролюкс как исправить ошибку
  • Ошибка illegal character u00bb java
  • Ошибка i30 посудомоечной машины electrolux что делать если она
  • Ошибка i20 в посудомоечной машине electrolux как устранить ошибку