For homebrew mysql installs, where's my.cnf?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
With Homebrew MySQL installs, my.cnf is often not present until you create it yourself. The important point is not one magical fixed path, but the search order MySQL uses plus the Homebrew prefix on your machine. On modern Homebrew setups, the most common config locations are /opt/homebrew/etc/my.cnf on Apple Silicon and /usr/local/etc/my.cnf on Intel Macs.
Check the Actual Search Paths First
Before guessing, ask the installed MySQL client where it looks for option files:
That output usually shows the option files MySQL will try to read in order. This is the most reliable starting point because it reflects the actual build and install you are using.
For Homebrew installs, these are the common locations to check:
If neither file exists, that does not necessarily mean the install is broken. It often just means no custom config file has been created yet.
The Usual Homebrew Locations
The common Homebrew convention is:
- Apple Silicon Homebrew prefix:
/opt/homebrew/etc/my.cnf - Intel Homebrew prefix:
/usr/local/etc/my.cnf
Those paths match Homebrew’s usual etc directory under the install prefix. If you are not sure which prefix your system is using, check:
That command gives you the Homebrew root, and the config path is usually under its etc directory.
Create my.cnf If It Does Not Exist
If you want a custom config and there is no existing file, create one in the Homebrew etc directory.
Example:
Then save it at the appropriate Homebrew path, for example:
or:
Use the path that matches your machine’s Homebrew prefix.
Restart MySQL and Confirm the Settings
After editing the file, restart the Homebrew MySQL service:
Then confirm a setting was actually loaded:
That check is important because creating a file in the wrong path can look correct on disk while having no effect at runtime.
Understand That More Than One Config File May Exist
MySQL can read several option files, and later files may override earlier settings. That is why blindly editing the first file you find can be misleading.
The safest workflow is:
- inspect MySQL’s search order
- choose one canonical Homebrew config file
- restart the service
- verify an effective variable in SQL
That prevents a lot of confusion during local development.
Homebrew and MySQL Version Differences
The exact package name may differ by formula, such as mysql, [email protected], or a MariaDB alternative. The search-path inspection command is still the right source of truth because it reports the running client’s own option-file behavior.
That is better than relying on a blog post that assumes one specific Homebrew era or formula name.
Common Pitfalls
One common mistake is assuming Homebrew always ships a populated my.cnf. Often there is no custom config file until you create one.
Another mistake is editing the wrong prefix path. Apple Silicon and Intel Homebrew installs usually use different roots, so /usr/local/etc/my.cnf is not universal anymore.
Developers also sometimes change the config and forget to restart the MySQL service. In that case, the file exists but the server is still running with the old settings.
Finally, do not assume the file is active just because it exists. Always verify with mysql --help and SHOW VARIABLES.
Summary
- The usual Homebrew
my.cnfpaths are/opt/homebrew/etc/my.cnfand/usr/local/etc/my.cnf. - '
mysql --helpis the best way to see the actual option-file search order for your install.' - If no
my.cnfexists, you can create one in the Homebrewetcdirectory. - Restart MySQL after editing the config.
- Verify the loaded settings from SQL instead of assuming the file is being read.
Related reading
- For loop example in MySQL
- Force drop mysql bypassing foreign key constraint
- Force reload the clickhouse config?
- Foreign key between two databases
- Foreign key constraints When to use ON UPDATE and ON DELETE
- Formatting IPv6 as an int in C and storing it in SQL Server
- Frequent Setup and Tear Down of SQL Server Replication
- From an array of ids to an array of names mongo, nodejs

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.