Remote Accessing HomeBrew'd MySQL on MacOS

I've recently been proof of concepting a new idea for work. It involves local and external access to MySQL servers. While transitioning from local development to a Vagrant VM I discovered the VM couldn't access my host local MySQL server.

Googling turned up some obvious answers, find my.cnf and remove bind_address = 127.0.0.1. I had installed MySQL using HomeBrew which installed MySQL to /usr/local/Cellar/mysql/5.7.10. My my.cnf configuration file was located in support_files within this directory. Much to my dismay there was no bind_address = 127.0.0.1.

Running sudo lsof -i -n -P | grep mysql within the shell told me MySQL was indeed binding to 127.0.0.1 despite the configuration file. Executing ps aux | grep -i mysqld was more enlightening, telling me the daemon was being passed the bind_address argument directly. This led me to the DBA Exchange post giving me what I needed:

  1. Edit /usr/local/Cellar/mysql//homebrew.mxcl.mysql.plist
  2. replace --bind-address=127.0.0.1 with bind-address=* or --bind-address=0.0.0.0 (see MySQL documentation on bind-address)
  3. Restart mysql using brew services restart mysql