MAMP MySQL无法识别OSX中的my.cnf值
作者:互联网
试图永久地使用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'
文件位置:
/应用/甲基苯丙胺/库/ 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 |
+--------------------------+--------------------------------------------+
在各种db之间切换将获得两个_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是否缺少信息,语法错误?或者订单重要吗?
谢谢.
解决方法:
在my.cnf文件的[mysqld]组中包含skip-character-set-client-handshake,一切似乎都正确配置,UTF8直通.我仍然不确定为什么[客户]组中的default-character-set = utf8没有带到这里,但我是一个新手,所以希望有人可以在那里发光.
你必须在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的评论中提到的解决方案.
标签:mysql,utf-8,mamp,configuration-files,my-cnf 来源: https://codeday.me/bug/20190726/1540409.html