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

15,661

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;
Share:
15,661
Sajeev C
Author by

Sajeev C

Updated on June 26, 2022

Comments

  • Sajeev C
    Sajeev C almost 2 years

    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.

  • krsoni
    krsoni almost 4 years
    mysql v8.0.18 shows warning about utf8 being alias to a deprecated UTF8MB4, so giving the new charset works well: ALTER TABLE xyz CONVERT TO CHARACTER SET UTF8MB4;