I inserted the word CAFE
in name
field mySQL table.
Unexpectedly, I get a row containing CAFE
when I execute below statement
SELECT * FROM myTable where name='CAFÉ';
, which is wrong. In my use-case CAFE
shouldn't be equal to CAFÉ
I think I set all the encodings correctly on server and client side:
Server side:
By modifying /etc/mysql/my.cnf
I get below
mysql> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
Client Side:
connect = DriverManager
.getConnection("jdbc:mysql://"+serverName+"/" +
dataBaseName + "?characterEncoding=utf8&user=" + userName + "&password=" + password);
p.s. there are many duplicate questions similar to this, but none of them answering specific to what I am running into.