Mysql – collation_database, collation_connection, collation_server used for in MySQL

collationdatabase connectionMySQL

Illegal mix of collations (big5_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like'

Sometimes this error is throw, what's up?
What's the collation_* used for?
Can someone give me an example to show how the character is encoded, transited and selected, relate to collation_*?

Best Answer

In MySQL,every table has a table character set and a table collation.

Collation is a set of rules on how to compare and sort character strings.

Every MySQL collation belongs to a single character set and every MySQL character set can have one or more collations which belong to it.

Mysql uses binary_key for sorting character sets, the new weight_string function available in MySQL 5.2 converts the character to-be compared to binary_key.

SELECT WEIGHT_STRING('a'); 

gives 0x41.

SELECT WEIGHT_STRING('A'); 

gives 0x41.

This pdf from Mysqlwiki has examples for what you want!