Mysql – Cant read dir of /etc/the.cnf. (Errcode: 2)

mariadbMySQL

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

Best Answer

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.