mysqlcollation

What is the difference between latin1_general_ci and utf8_bin in MySQL


I am currently working with multi-lingual site. In some cases I need to save the other language data in the database. While I did it does not save the actual data what i entered. Instead of it contains ?????????????????????. After that I changed the collation latin1_general_ci into utf8_bin.

Then its working well now.

could anyone explain me the differences between collation available in MySQL

Thanks in Advance.


Solution

  • utf8_bin: compare strings by the binary value of each character in the string

    utf8_general_ci: compare strings using general language rules and using case-insensitive comparisons

    utf8_general_cs: compare strings using general language rules and using case-sensitive comparisons

    For example, the following will evaluate at true with either of the UTF8_general collations, but not with the utf8_bin collation: Code:

    Ä = A
    Ö = O
    Ü = U
    

    With the utf8_general_ci collation, they would also return true even if not the same case.

    None of these is inherently "better"; they simply have different functionalities. You need to choose which one best suits your particular needs.