Reputation: 656
I'm losing my mind on this issue since yesterday.
I'm trying to convert my MySQL database from utf8 to utf8mb4. To do so, I followed those sites/threads : https://mathiasbynens.be/notes/mysql-utf8mb4#utf8-to-utf8mb4 , Cannot store emoji in database , Change MySQL default character set to UTF-8 in my.cnf? , etc.
My database seems to have a utf8mb4_unicode_ci collation
as expected, and all her tables too.
Nevertheless, when I proceed SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
I obtain :
#With a Root access
Variable_name Value
character_set_client utf8 #expecting utf8mb4
character_set_connection utf8 #expecting utf8mb4
character_set_database utf8mb4 #good
character_set_filesystem binary #good
character_set_results utf8 #expecting utf8mb4
character_set_server utf8mb4 #good
character_set_system utf8 #expecting utf8mb4
collation_connection utf8_general_ci #expecting utf8mb4_unicode_ci
collation_database utf8mb4_unicode_ci #good
collation_server utf8mb4_unicode_ci #good
#With a standard user access
Variable_name Value
character_set_client utf8 #expecting utf8mb4
character_set_connection utf8mb4 #good
character_set_database utf8mb4 #good
character_set_filesystem binary #good
character_set_results utf8 #expecting utf8mb4
character_set_server utf8mb4 #good
character_set_system utf8 #expecting utf8mb4
collation_connection utf8mb4_unicode_ci #good
collation_database utf8mb4_unicode_ci #good
collation_server utf8mb4_unicode_ci #good
I set a /etc/mysql/conf.d/90-my.cnf
file like this :
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect = 'SET collation_connection = utf8mb4_unicode_ci'
init-connect = 'SET NAMES utf8mb4'
My MySQL version is 5.5.54, all set in a debian 7.
Does anyone have a clue to help me ?
Thx for your help, and sorry for my bad english...
EDIT
Fun fact : when I check variables in the in-line command, I got this :
mysql> show variables like "%character%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
While I still have utf8
for character_set_client
and character_set_results
when I check with phpmyadmin (with a non-superuser access)
Upvotes: 4
Views: 6545
Reputation: 142278
When connecting as user root
, init-connect
is ignored.
Give your application its own login without SUPER
privilege.
Then, to make extra sure, whenever establishing a connection from your app, do the language-specific method of providing the character set. (Or execute SET NAMES utf8mb4
.) What app language are you using?
In case something else is going wrong, see "Best Practice" in Trouble with utf8 characters; what I see is not what I stored
Upvotes: 2