尝试永久使用UTF8,无法让MAMP安装MySQL来识别my.cnf值。
MAMP 版本2.0.5(2.0.5)
MySQL 5.5.9
my.cnf文件:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
collation_server=utf8_general_ci
character_set_server=utf8
init-connect='SET NAMES utf8'
档案位置:
/应用/ MAMP /库/ CONF /
启动时的MySQL varibles:
mysql> show variables where variable_name LIKE '%char%' OR variable_name LIKE '%colla%';
+--------------------------+--------------------------------------------+
| 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 | /Applications/MAMP/Library/share/charsets/ |
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+--------------------------+--------------------------------------------+
在各种数据库之间切换将获得两个_database
值到utf8,但我似乎无法获得两个_server
选项来反映utf8 / utf8_unicode_ci:
use tsdb;
+--------------------------+--------------------------------------------+
| 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 | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /Applications/MAMP/Library/share/charsets/ |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | latin1_swedish_ci |
+--------------------------+--------------------------------------------+
尝试
set global character_set_server = utf8;
等,但它没有重新启动。
这是我第一次搞乱my.cnf所以我确定我忽略了一些基本的东西。 my.cnf是否缺少信息,语法错误?或者订单重要吗?
感谢。
答案 0 :(得分:8)
在my.cnf文件的[mysqld]组中包含skip-character-set-client-handshake
,所有内容似乎都已正确配置,UTF8直通。我仍然不确定为什么default-character-set=utf8
组中的[client]
没有带到这里,但我是新手,所以希望有人可以在那里发光。
你必须在Applications / MAMP / conf和IN MAMP Pro中创建my.cnf,你可以在File>下找到编辑模板> MySQL my.cnf进行更改。
的my.cnf:
# The MySQL server
[mysqld]
skip-character-set-client-handshake
collation_server=utf8_unicode_ci
character_set_server=utf8
结果:
mysql> SHOW VARIABLES WHERE variable_name LIKE '%char%' OR variable_name LIKE '%colla%';
+--------------------------+--------------------------------------------+
| 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 | /Applications/MAMP/Library/share/charsets/ |
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+--------------------------+--------------------------------------------+
这也解决了为什么mysqladmin的变量与mysql的不同,每个变量使用SHOW VARIABLES
时。
MySQL手册here的评论中提到的解决方案。