Sep 13, 2018

How to find / check which MySQL configuration file my.cnf are being used

There is no internal MySQL command to trace which MySQL configuration file are being used. There might be 5 locations. They load cascading.

  • /etc/my.cnf
  • /etc/mysql/my.cnf
  • $MYSQL_HOME/my.cnf
  • [datadir]/my.cnf
  • ~/.my.cnf

Those are the default locations MySQL looks at. If it finds more than one, it will load each of them & values override each other (in the listed order, I think). Also, the --defaults-file parameter can override the whole thing.

If you just want to see the values: SHOW VARIABLES.

You can find out how many my.cnf files exist in your system:

$ sudo find / -name my.cnf