MySQL
Homebrew
my.cnf
Database Configuration
MacOS

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.

Practice system design

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:

bash
mysql --help | grep -A 1 "Default options"

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:

bash
ls /opt/homebrew/etc/my.cnf
ls /usr/local/etc/my.cnf

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:

bash
brew --prefix

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:

ini
1[mysqld]
2max_connections=200
3innodb_buffer_pool_size=512M
4bind-address=127.0.0.1
5
6[client]
7default-character-set=utf8mb4

Then save it at the appropriate Homebrew path, for example:

bash
nano /opt/homebrew/etc/my.cnf

or:

bash
nano /usr/local/etc/my.cnf

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:

bash
brew services restart mysql

Then confirm a setting was actually loaded:

bash
mysql -u root -p -e "SHOW VARIABLES LIKE 'max_connections';"

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:

  1. inspect MySQL’s search order
  2. choose one canonical Homebrew config file
  3. restart the service
  4. 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.cnf paths are /opt/homebrew/etc/my.cnf and /usr/local/etc/my.cnf.
  • 'mysql --help is the best way to see the actual option-file search order for your install.'
  • If no my.cnf exists, you can create one in the Homebrew etc directory.
  • Restart MySQL after editing the config.
  • Verify the loaded settings from SQL instead of assuming the file is being read.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track 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.

Practice system design

All Rights Reserved.