Topic on Project:Support desk

"Illegal mix of collations" error

5
Jonathan3 (talkcontribs)

I get the following error (when recreating table data on the Cargo extension, but I'm sure it's not that extension's fault) for pages with some non-English characters (e.g. in the name Šikuta):

Function: Wikimedia\Rdbms\Database::select

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

Looking at my MediaWiki database, it seems to be a mixture of utf_general_ci and latin1_swedish_ci. The Cargo database is all latin1_swedish_ci. The default collation for both is latin1_swedish_ci.

I think I need to alter each latin1_swedish_ci table so that it is utf_general_ci and change the default for future tables being created.

Is this the solution? Would there be any unintended consequences of doing this? Is there an easy way you could recommend (e.g. a maintenance script which already exists)? Thanks. ~~~~


2001:16B8:10F1:AE00:19A2:0:C3E2:94E9 (talkcontribs)

MediaWiki always creates output for storage in the database in UTF-8. The database should be set to either utf8 or binary.

So, yes, you should make sure there is no latin1_swedish in your DB. This will include change the column charsets, the table and the database charset.

Jonathan3 (talkcontribs)

Thank you. I vaguely remember when installing MediaWiki for the first time (in 2006) getting an error about a key being too long (?) and having to reduce the length of something... anyway, it was probably to do with this same thing! ~~~~

TheDJ (talkcontribs)

Yes older versions of mysql had a maxsize issue with indexes. This was fixed in php 5.6 if i remember correctly.

It's also worth noting that mixing encodings (and collations) can impact index performance, so that's another reason to get everything aligned.

Jonathan3 (talkcontribs)

@TheDJ Sorry for resurrecting this, but what impact if any does this - T194125 - have?

Reply to ""Illegal mix of collations" error"