3

I am running MariaDB (libmysql - 5.5.41-MariaDB) and today I noticed that I couldn't go to mysql via command line to create a dump file. It would throw an error:

mysql: Can't read dir of '/etc/my.cnf.' (Errcode: 2) Fatal error in defaults handling. Program aborted

Not sure why it needs to read a directory named "my.cnf." but I do see a directory called "my.cnf.d" in etc folder. Possibly a typo of some sort but when I went to my my.cnf file, I didn't notice any settings for this. The only thing closely relates to it is this:

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

This is something that recently occurred without me changing anything in the settings so I am not sure what is going on with mariadb. Any help would be appreciated.

EDIT: Okay, I solved the issue by doing mkdir my.cnf. (not sure what this directory is needed for as nothing is inside it. Never changed anything to my.cnf for it to start requiring this directory..

5
  • A typo somewhere in the real my.cnf?
    – ott--
    Aug 24, 2015 at 17:36
  • Make sure any directories being called by !includedir exist and that you have permission to access them. Also, it would help to see the full my.cnf file, to see if there are any errors in it. Plus, make sure your user's ~/.my.cnf is accurate as well.
    – Gene
    Aug 24, 2015 at 17:44
  • What happens when you run mysql --no-defaults ... ?
    – user9517
    Aug 24, 2015 at 18:54
  • @iain that seems to work, I get "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)". Aug 24, 2015 at 19:36
  • @Gene the my.cnf.d directory does exist, here is the permissions. drwxr-xr-x. 2 root root 4096 Mar 3 15:53 my.cnf.d Aug 24, 2015 at 19:38

6 Answers 6

1

Given that it works when you disable reading the defaults (--no-defaults) then the problem is located somewhere in the default files, their permissions or the permissions of the directories containing them.

Carefully examine the permissions on /etc, /etc/my.cnf, /etc/my.cnf.d, the files inside /etc/my.cnf.d as well as for good measure ~/.my.cnf.

Check the contents of each file for more includes and any other directives that may access files.

If SELinux is enabled, check the contents of /var/log/audit.log for relevant AVC denied entries.

2
  • I'm not sure what permission it should be set to nor do I know which are the default files. The error is throwing that it can't read directory 'my.cnf.' and I can see that I do not have a directory named 'my.cnf.', I do have directory 'my.cnf.d' so not sure what to do from there or where can I go to correct this. Aug 25, 2015 at 1:17
  • Okay, I solved the issue by doing mkdir my.cnf. (not sure what this directory is needed for as nothing is inside it. Never changed anything to my.cnf for it to start requiring this directory.. Aug 25, 2015 at 1:23
8

the solution actually is simple.


!includedir /etc/my.cnf.d

is your last line on /etc/my.cnf, so mysql can't read complete '/etc/my.cnf.d' only '/etc/my.cnf.'

You just need add one more line so mysql can read its.


!includedir /etc/my.cnf.d
# add new line here
2
  • 1
    This is the correct answer!
    – Arkhitech
    Apr 28, 2016 at 20:49
  • @triads can you please explain what is new line to add end my.cnf file May 17, 2016 at 9:37
1

You must add new empty line after !includedir /etc/my.cnf.d

!includedir /etc/my.cnf.d

EMPTY LINE

You must simply press 'enter' in the end of this line:!includedir /etc/my.cnf.d

1
  • This worked for me; after I had edited the said file I removed this empty line inadvertently.
    – Natetronn
    Oct 12, 2017 at 7:04
0

Very strange: The failure occured also suddenly (after restarting the docker container) - in MySQL Ver 14.14 Distrib 5.7.23, Debian 9.5, Docker 17.12.1-ce

Trying a lot of stuff didn't work, all permissions where correct (afaik).

The last option was to follow the "Edit" of the question-author and that worked!

I did:

mv /etc/my.cnf /etc/_my.cnf    # there was just the line [mysql] in it, nothing else
mkdir /etc/my.cnf
chown mysql:mysql /etc/my.cnf

now after running service mysql start it suddenly says: "A MySQL Server is already started". After service mysql restart all is working like before the shutdown of the docker conatainer.

0
0

This no Connection happens to me every couple times I restart my MacBook. I think it has something to do with competing versions of Mysql. Native Mac MySql VS. Brew MySql. This is all I need to do:

sudo mkdir /usr/local/etc/my.cnf.d

Then restart my terminal. I reference this article every month or two The /usr/local/etc/my.cnf has an includes for /usr/local/etc/my.cnf.d directory, and that fails if the directory isn't there. So I just need to create the directory. Annoying little bug, but easy to fix.

0

I have solved this issue in macOS Catalina mariadb.

mkdir /usr/local/etc/my.cnf.d

brew services stop mariadb

brew services start mariadb

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .