Reputation: 707
I want to insert some items with some Japanese and Chinese in MySQL 5 on mac os 10.8 using mysql-java driver.
But I found all the international character becaome ?????.
I googled and found it's the problem of character_set_server.
I checked it with the command: show variables like 'character%', and found the character_set_server is latin now.
I want to change it to utf-8 and found most of the solution on internet is to modify the my.cnf file to:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
But I cannot find my.cnf on my mac. I just find a my-default.cnf under /usr/local/mysql/support-files/.
I changed it and restart mysql, nothing changed.
Then I created a my.cnf under /etc and put the content above in it. Restart mysql, still nothing changed.
I don't know how to fix it and I am really in a hurry.
Upvotes: 2
Views: 5508
Reputation: 183
i saw your issue when i was searching the same question:why chinese charater stored in mysql became ????(i already deal the charset issue in my webapp) and how to change character_set_server of MySQL on mac(i cant find my.cnf on my mac too);
Here's the solution:
1.copy my-default.cnf from /usr/local/mysql/support-files/
to /etc
(my-default.cnf is just a template);
2.rename my-default.cnf to my.cnf;
3.stop mysql server in System Preferences(or may encounter can't connecting to mysql sock issue);
4.edit my.cnf, add character-set-server = utf8
behind [mysqld]
;
5.save the file and running mysql server and restart mysql;
after doing this, i successfully changed my mysql character_set_server to utf8, and chinese characters in mysql were good;
Upvotes: 2
Reputation: 707
I found the way: to modify the my.cnf in the /usr/local/mysql... directory.
Upvotes: 0