MySQL – Understanding ~/.my.cnf Configuration

configurationlinuxmy.cnfmysql-5.1

When I run $ mysqld --verbose --help | less I got information like

Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf

As per my understanding, At startup, mysql first look for my.cnf within /etc/mysql/my.cnf then within /etc/my.cnf and then finally ~/.my.cnf.

  • Am I correct?
  • Which directory does this mean – ~/.my.cnf?
  • If a variable x has value 100 in /etc/mysql/my.cnf and again the same variable x has value 200 in etc/my.cnf, What value will really apply?

Best Answer

~/.my.cnf is .my.cnf file in your home directory. The meaning of tilde ~ in unix is current user's home directory.

The values from different configurations are overwritten. So /etc/my.cnf will overwrite was what defined in /etc/mysql/my.cnf, and ~/.my.cnf will overwrite what was in previous files.