MySQL 5.6 Configuration
I have configured /etc/mysql/my.cnf
manually to use utf8
. See below:
[mysqld]
character-set-server=utf8
character-sets-dir=/usr/share/mysql/charsets
[mysql]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqladmin]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlcheck]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqldump]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlimport]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlshow]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[client]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
From console:
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| 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.01 sec)
Application configuration
Now for the web-app I used both of this connection url in Tomcat's context.xml
url="jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"
url="jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=utf8&connectionCollation=utf8_general_ci"
Above does not work and gives me following for the application.
show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
What might be wrong here? Why it is showing utf8mb4
instead utf8
?