Docker Container の MySQL に接続しようとしたところ、
MySQLクライアントに Can't read dir of '/usr/local/etc/my.cnf.d'
と言われてしまった。
$ docker run --name local-db -itd -p 3306:3306\
-e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_USER=t_horikoshi\
-e MYSQL_PASSWORD=t_horikoshi \
-d mysql:5.6 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci \
--innodb-large-prefix=true \
--innodb-file-format=Barracuda \
--innodb-file-per-table=true
298fa19aa73229c5d4c3902ac6578e880d8741ac324a9f56de7f3e5163138ad0
$ docker start local_db
local_db
$ mysql -h 127.0.0.1 -u root -p
mysql: Can't read dir of '/usr/local/etc/my.cnf.d' (OS errno 2 - No such file or directory)
mysql: [ERROR] Fatal error in defaults handling. Program aborted!
なんか my.cnf.d
が無いらしい 😵
/usr/local/etc/ の中身を確認
$ cd /usr/local/etc/
$ ls
bash_completion dnsroots.global gitconfig mongod.conf openssl sbtopts
bash_completion.d fish init.d my.cnf pkcs11 unbound
brew-wrap fonts logrotate.d my.cnf.default profile.d
確かに my.cnf.d
は見当たらない。
my.cnf.d を作ってみる
無いんだから作ればいいんでしょ?
$ mkdir my.cnf.d
動作確認
$ mysql -h 127.0.0.1 -u root -p
Enter password: # root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 991
Server version: 5.6.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
無事解決しました。
※my.cnf.d
はディレクトリじゃないとダメっぽい。