How can I make SQL case sensitive string comparison on MySQL?

前端 未结 11 2207
温柔的废话
温柔的废话 2020-11-22 02:45

I have a function that returns five characters with mixed case. If I do a query on this string it will return the value regardless of case.

How can I make MySQL stri

11条回答
  •  花落未央
    2020-11-22 03:19

    Following is for MySQL versions equal to or higher than 5.5.

    Add to /etc/mysql/my.cnf

      [mysqld]
      ...
      character-set-server=utf8
      collation-server=utf8_bin
      ...
    

    All other collations I tried seemed to be case-insensitive, only "utf8_bin" worked.

    Do not forget to restart mysql after this:

       sudo service mysql restart
    

    According to http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html there is also a "latin1_bin".

    The "utf8_general_cs" was not accepted by mysql startup. (I read "_cs" as "case-sensitive" - ???).

提交回复
热议问题