Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Number: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='

Table Name: xyz Type: InnoDB Collation:latin1_swedish_ci

Fields:

---------------------------------------------------------------------------
            Field        | Type        | Collation         | Extra        |
---------------------------------------------------------------------------
            id           | int         |                   | Primary Key  |
---------------------------------------------------------------------------
            name         | varchar     | latin1_swedish_ci |              |
---------------------------------------------------------------------------

This is my database table. And When I am trying to insert a value for name something like this

If T₀, T₁, T₂ . . . . . . . Tn represent the terms in the expansion of (x + a)n, then (T₀ - T₂ + T₄ - . . )2 + (T₁ - T₃ + T₅ - . . )2 

I get the following error:

Error Number: 1267Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='

I did a quick research & found many S.O questions and articles providing solutions but none of them worked for me.

My Reference: Visit

I tried changing the collation of the table using a query like this:

ALTER TABLE xyz CHARACTER SET utf8 COLLATE utf8_general_ci;

But the error remained still.

I also tried using utf8_unicode_ci but that also didn't work.

Reasons? Solutions? Gracias.

like image 736
Sajeev C Avatar asked Jun 30 '15 06:06

Sajeev C


People also ask

What does illegal mix of collations mean?

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.

What is default collation in MySQL?

The default MySQL server character set and collation are latin1 and latin1_swedish_ci , but you can specify character sets at the server, database, table, column, and string literal levels.

What is character set in MySQL?

A character set in MySQL is a set of characters, encodings, and symbols that are legal in a string. This article explains how we can get all character sets in MySQL, how we can configure proper character sets for client connections, and how we can convert strings between multiple character sets.


1 Answers

Thanks to @vhu for marking this as duplicate.

Answer Courtesy: @Marvin W

I modified my table and that fixed my problem.

ALTER TABLE xyz CONVERT TO CHARACTER SET utf8;
like image 152
Sajeev C Avatar answered Oct 30 '22 22:10

Sajeev C