5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLクライアントに Can't read dir of '/usr/local/etc/my.cnf.d' と言われた。

Posted at

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 はディレクトリじゃないとダメっぽい。

おしまい

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?