mac系统mysql5.6.17修改字符集

在mysql官网上下载最新的mysql for MacOS 5.6.17(dmg版本)安装过程中没有发现让选择字符集的位置,安装成功以后
mysql> show variables like '%char%';
+--------------------------+--------------------------------------------------------+
| Variable_name            | Value                                                  |
+--------------------------+--------------------------------------------------------+
| character_set_client     | utf8                                                   |
| character_set_connection | utf8                                                   |
| character_set_database   | latin1                                                 |
| character_set_filesystem | binary                                                 |
| character_set_results    | utf8                                                   |
| character_set_server     | latin1                                                 |
| character_set_system     | utf8                                                   |
| character_sets_dir       | /usr/local/mysql-5.5.23-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
发现character_set_database和character_set_server依然是latin1的字符集
在网上搜索方法,都说
sudo cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
经测试发现/usr/local/mysql/support-files下没有my-medium.cnf
所以需要自己在/etc下创建一个my.cnf
在创建的my.cnf中添加
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
保存发现mysql启动不了了
后来经过查找在my.cnf中添加如下
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
保存后启动mysql,发现正常启动
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/local/mysql-5.6.17-osx10.7-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)

字符集已修改完毕

在网上搜索都没有很明确的答案,记录一下,欢迎MacOS大手拍砖,鄙人MacOS小白,第一次玩MacOS mysql

你可能感兴趣的:(mysql5.6)