Skip to main content

Illegal mix of collations

❌ Error

Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operation '='

📍 Context

This error occurs when MySQL tries to compare two strings that use different collations (for example, utf8mb4_general_ci vs. utf8mb4_unicode_ci). It often happens in FiveM scripts when queries involve player data (e.g. plates, names, identifiers) stored with inconsistent collations.

✅ Solution

There are two ways to fix this:

  1. Unify the entire database collation (recommended)

     ALTER DATABASE your_database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    This ensures all tables and queries use the same collation.

  2. Adjust specific tables or columns

    • Drop or alter the affected tables.
    • Modify the SQL schema to use a consistent collation (utf8mb4_unicode_ci or utf8mb4_general_ci).
    • Recreate or migrate the data.

ℹ️ Additional Information

  • Always back up your database before applying structural changes.
  • Using utf8mb4_unicode_ci is generally preferred, as it provides better Unicode support.
  • Mixing collations across tables can lead to unpredictable query errors.
  • For more details on MySQL collations, refer to the MySQL documentation.