MAMP MySQL 无法识别 OSX 中的 my.cnf 值
尝试永久使用 UTF8,但无法让 MAMP 安装的 MySQL 识别 my.cnf 值。
曼普 版本 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'
文件位置:
/Applications/MAMP/Library/Conf/
启动时的 MySQL 变量:
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 是否缺少信息,语法是否错误?还是顺序重要?
谢谢。
Trying to go UTF8 permanently and can't get MAMP's install of MySQL to recognize my.cnf values.
MAMP
Version 2.0.5 (2.0.5)
MySQL 5.5.9
my.cnf file:
[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'
Location of file:
/Applications/MAMP/Library/Conf/
MySQL varibles on startup:
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 |
+--------------------------+--------------------------------------------+
Switching between various db's will get both _database
values to utf8, but I can't seem to get both _server
options to reflect 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 |
+--------------------------+--------------------------------------------+
Tried
set global character_set_server = utf8;
etc, but it didn't take on restart.
This is my first time messing with my.cnf so I'm sure I'm overlooking something basic. Is there info missing from my.cnf, is the syntax wrong? Or is order important?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 my.cnf 文件的 [mysqld] 组中包含
skip-character-set-client-handshake
,一切似乎都已正确配置,直接通过 UTF8。我仍然不确定为什么[client]
组中的default-character-set=utf8
没有接受这里,但我是新手,所以希望有人可以在那里照亮。您必须在Applications/MAMP/conf 和MAMP Pro 中创建my.cnf,您可以在“文件”>“文件”下创建my.cnf。编辑模板> MySQL my.cnf 进行更改。
my.cnf:
结果:
这也解决了为什么 mysqladmin 的变量与 mysql 的变量在使用
SHOW VARIABLES
时不同。MySQL手册注释中提到的解决方案这里。
Included
skip-character-set-client-handshake
in the [mysqld] group of the my.cnf file and everything seems correctly configured, UTF8 straight through. I'm still not sure whydefault-character-set=utf8
in the[client]
group didn't take here, but I'm a newbie so hopefully someone can shed light there.You must create my.cnf in Applications/MAMP/conf and IN MAMP Pro, you go under the File > Edit Template > MySQL my.cnf to make the changes.
my.cnf:
Results:
This also solved why mysqladmin's variables were different than mysql's when using
SHOW VARIABLES
for each.Solution mentioned in comments of MySQL manual here.