Skip to content
Advertisement

How to convert all tables in database to one collation?

I’m getting error:

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

I tried changing both tables manually to utf8_general_ci,IMPLICIT but I’m still getting the error.

Is there a way to convert all tables to utf8_general_ci,IMPLICIT and be done with it?

Advertisement

Answer

You need to execute a alter table statement for each table. The statement would follow this form:

Now to get all the tables in the database you would need to execute the following query:

So now let MySQL write the code for you:

You can copy the results and execute them. I have not tested the syntax but you should be able to figure out the rest. Think of it as a little exercise.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement