所以我按照"教程"这里:
http://outofcontrol.ca/blog/comments/change-mysql-5.5-default-character-set-to-utf8
在这样做之后,linux上的mysql 5.7服务器正常更新,一切都按照我的预期显示。
但是,我在我的开发机器,Macbook Pro,El Capitan上做了同样的事情,我看到了以下内容:
character_set_client utf8
character_set_connection utf8
**character_set_database latin1**
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
character_sets_dir /usr/local/mysql-5.6.10-osx10.7-x86_64/share/charsets/
为什么这仍然是latin1?其他条目更新为utf8,这适用于linux。
答案 0 :(得分:2)
character_set_database
is of virtually no use. Don't worry about it.
When creating a table, explicitly state
CREATE TABLE (...) ... CHARACTER SET utf8;
That helps you avoid various changes to defaults that may occur now or in the future.
Actually, the future is likely to be utf8mb4
with collation utf8mb4_unicode_520_ci
.
As long as you are going to 5.7, you may as well go to that combo. utf8mb4 lets you get to Emoji and the rest of the Chinese character set; the 520 collation is arguably "more correct".
The link you gave is a bit weak -- it does not explain how to convert any data you have.
Existing tables are not changed by changing the settings you mentioned.
So, what is the whole picture? Do you have existing data? In utf8 or latin1? Are you updating in place? Or dumping and reloading? Etc.