• Resolved Irene

    (@arlinaite)


    Hi,
    I have the following error:
    Error Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_unicode_520_ci,COERCIBLE) for operation 'like'

    I use WP Multisite install 5.6 and MySQL 5.7

    The posts and postmeta tables are in utf8_general_ci
    Most of the Redirection and Plugin tables are utf8mb4_unicode_520_ci

    Questions:

    1)Its safe to change table and columns from utf8_general_ci to utf8mb4_unicode_520_ci to avoid “Illegal mix of collations”?
    2)There is something to change in the wp-config.php?

    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');

    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    Leaving DB_COLLATE blank means the default will be used. If you’re sure everything is utf8mb4_unicode_520_ci, you can go ahead and specify that, but if that’s the default anyway, it won’t matter. Note that the DB itself also has an overall collation setting aside from tables and columns.

    You can safely go from utf8_* to utf8mb4_* but not the other way around. utf8 is limited to 3 byte or less encoding. utf8mb4 recognizes 4 byte or less encoding. I suppose if you’re sure you don’t have any 4 byte characters, you could go from 4 to 3 byte, but there’d be no reason to since 4 byte is what we want.

    Thread Starter Irene

    (@arlinaite)

    Thanks for your answer

    Data base is latin_swedish_ci
    Post and postmeta tables are utf8_general_ci
    Redirect and some other plugins tables are utf8mb4_unicode_520_ci
    Wordfence tables has latin_swedish_ci and utf8_general_ci

    Should I move all to utf8mb4_unicode_520_ci including the Data base collate?
    This is the last standard?

    As a you say to avoid issues is better not to downgrade. I don’t need to, I am not planning to use older version of MySQL

    About the wp-config file

    Leaving DB_COLLATE blank means the default will be used.

    This is blank now

    I don’t understand if the charset in the wp-config should be as it is utf8or should be changed to blank too

    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    Moderator bcworkz

    (@bcworkz)

    Charset and collation are two different things (but are related). Collation affects the ordering of alphabetical results. For most of us using Latin alphabets, collation choice wouldn’t make much difference. It’s just that SQL isn’t capable of handling mixed collations. OTOH charset encoding affects the data itself. Using mismatched encoding will cause strange characters to appear in your content. So don’t mess with encoding unless you’re sure you know what you’re doing.

    You can likely switch collations without anything dramatic happening unless your locale has specific ordering needs, like is ü after U or after Z? utf8mb4 is the latest collation for utf8 charset. Whether it’s general, unicode, or swedish depends on your locale. The “ci” part means case insensitive, a is ordered with A, etc.

    TBH, I don’t know how unicode_520 is different than general. If your language uses only the 26 English letters, it likely makes no difference. I suggest using whichever is most predominant, just to limit how many changes need to be made. While there is little risk in changing collations, please make a full DB backup before making any changes. Then change collations to be consistent through out.

    Thread Starter Irene

    (@arlinaite)

    Thanks!! very detail explanation.

    In the site I have English and Spanish.
    Spanish has 27 letters because we have letter ? ?, and also orthographic accent like: á é í ó ú

    May be you know if there is something special with Spanish?
    I read that each collation has its own set of characters. The most used collation in database seems utf8mb4_unicode_520_ci that comes with Unicode (UCA 5.2.0), case-insensitive. However I didn’t find what is and if its good for Spanish.

    Sorry that I do so many questions, but researching on Google I couldn’t find the explanation that you give me here.

    Very grateful for your time

    Moderator bcworkz

    (@bcworkz)

    I’m pretty sure any Unicode version covers all Latin chars. Whether it alphabetizes correctly for your Spanish locale I couldn’t say. My guess is it’ll be fine, I imagine lots of Spanish language sites use it. It’s not like it’s an obscure language ??

    Thread Starter Irene

    (@arlinaite)

    Thanks you gave me an excellent and fast answer!! I am sure it will be helping many others with same doubts

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Illegal mix of collations’ is closed to new replies.