MAMP MySQL无法识别OSX中的my.cnf值 [英] MAMP MySQL not recognizing my.cnf values in OSX

查看:77
本文介绍了MAMP MySQL无法识别OSX中的my.cnf值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图永久使用UTF8,并且无法安装MAMP的MySQL来识别my.cnf值.

Trying to go UTF8 permanently and can't get MAMP's install of MySQL to recognize my.cnf values.

MAMP 版本2.0.5(2.0.5)

MAMP Version 2.0.5 (2.0.5)

MySQL 5.5.9

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/

/Applications/MAMP/Library/Conf/

启动时使用MySQL变量:

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                          |
+--------------------------+--------------------------------------------+

在不同数据库之间切换会同时将两个_database值都获取到utf8,但是我似乎无法同时获得这两个_server选项来反映utf8/utf8_unicode_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                          |
+--------------------------+--------------------------------------------+

尝试

set global character_set_server = utf8;

等,但没有重新启动.

这是我第一次弄乱my.cnf,所以我确定我忽略了一些基本知识. my.cnf是否缺少信息,语法是否错误?还是订单重要?

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?

谢谢.

推荐答案

my.cnf文件的[mysqld]组中包含的skip-character-set-client-handshake,所有内容似乎都已正确配置,并且是UTF8.我仍然不确定为什么[client]组中的default-character-set=utf8不在这里,但是我是新手,所以希望有人可以在那里阐明一下. 您必须在Applications/MAMP/conf和IN MAMP Pro中创建my.cnf,然后在文件">编辑模板">"MySQL my.cnf"下进行更改.

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 why default-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:

# 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                            |
+--------------------------+--------------------------------------------+

这也解决了为什么对于每个使用SHOW VARIABLES时mysqladmin的变量与mysql的变量不同的原因.

This also solved why mysqladmin's variables were different than mysql's when using SHOW VARIABLES for each.

MySQL手册注释中提到的解决方案此处

Solution mentioned in comments of MySQL manual here.

这篇关于MAMP MySQL无法识别OSX中的my.cnf值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆