Mac OS Catalina下my.cnf/mysql.conf配置文件位置查询
Hey there! I’ve dealt with this exact scenario before when using MySQL’s official .pkg installer instead of Homebrew—let’s break down where to locate (or create) your my.cnf file:
1. First, check where MySQL actually looks for config files
The easiest way to see all the paths MySQL will search by default is to run this terminal command:
mysqld --help --verbose | grep -A 1 "Default options"
You’ll get output that looks something like this (paths vary slightly by MySQL version):
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
For .pkg installs, /etc/my.cnf is the standard go-to location, but often the installer doesn’t create this file automatically—so that’s why you didn’t find it at first!
2. Create the config file if it doesn’t exist
If none of the listed paths have a my.cnf file, you can create one manually at /etc/my.cnf using a terminal text editor like nano:
sudo nano /etc/my.cnf
Add your desired configuration settings (wrap them in the appropriate sections, like [mysqld] for server settings). For example:
[mysqld] innodb_buffer_pool_size = 512M max_connections = 200
Save and exit nano by pressing Ctrl+O, hitting Enter, then Ctrl+X.
3. Restart MySQL to apply changes
After editing or creating the file, you’ll need to restart the MySQL service for changes to take effect. Use these commands:
sudo launchctl stop com.oracle.oss.mysql.mysqld sudo launchctl start com.oracle.oss.mysql.mysqld
Quick note on plist files
You might notice a plist file at /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist—this is just for managing how MySQL starts up on your Mac, not for database configuration settings. All your actual MySQL tweaks go in my.cnf.
内容的提问来源于stack exchange,提问作者Mathe Eliel

