Location of my.cnf file on macOS
This thread on the MySQL forum says:
By default, the OS X installation does not use a my.cnf, and MySQL just uses the default values. To set up your own my.cnf, you could just create a file straight in /etc.
OS X provides example configuration files at /usr/local/mysql/support-files/
.
And if you can't find them there, MySQLWorkbench can create them for you by:
- Opening a connection
- Selecting the 'Options File' under 'INSTANCE' in the menu.
- MySQLWorkbench will search for my.cnf and if it can't find it, it'll create it for you
In general, on Unix and Unix-like systems, MySQL/MariaDB programs read config/startup files in the following locations (in the specified order):
/etc/my.cnf
- Global/etc/mysql/my.cnf
- GlobalSYSCONFDIR/my.cnf
- GlobalSYSCONFDIR
represents the directory specified with theSYSCONFDIR
option toCMake
when MySQL was built. By default, this is the etc directory located under the compiled-in installation directory.$MYSQL_HOME/my.cnf
- Server-specific (server only)MYSQL_HOME
is an environment variable containing the path to the directory in which the server-specificmy.cnf
file resides. IfMYSQL_HOME
is not set and you start the server using themysqld_safe
program,mysqld_safe
sets it toBASEDIR
, the MySQL base installation directory.file specified with
--defaults-extra-file=path
if any~/.my.cnf
- User-specific~/.mylogin.cnf
- User-specific (clients only)
Source: Using Option Files.
Note: On Unix platforms, MySQL ignores configuration files that are world-writable. This is intentional as a security measure.
Additionally on Mac there is a simple way to check it.
Run:
sudo fs_usage | grep my.cnf
This will report any filesystem activity in real-time related to that file.
In another Terminal, restart your MySQL/MariaDB, e.g.
brew services restart mysql
or:
brew services restart mariadb
On terminal with
fs_usage
, the proper location should be shown, e.g.15:52:22 access /usr/local/Cellar/mariadb/10.1.14/my.cnf 0.000002 sh
So if the file doesn't exist, create one.
In case of Mac OS X Maverick when MySQL is installed via Homebrew it's located at /usr/local/opt/mysql/my.cnf