Solved: MySQL Server is Running on the Wrong Port on Mac OS X 10.10 (Yosemite), And It's Not The Configuration File!

This post is filed under “Troubleshooting,” but you could really file it under “obscure problems which have caused a disproportionate amount of frustration.”

Recently, my work computer fried itself, leaving me to migrate all of my data to a backup workstation (which was itself no small task). I work locally, of course, so as you’d expect, I brought over all of my sites, made sure all of my git repositories were in working order, and ensured that Apache and PHP were configured properly. Then came time to install MySQL.

Deciding to start fresh, I downloaded the MySQL cluster DMG archive from the MySQL Downloads page, which allows you to install MySQL server, a MySQL preference pane, and a MySQL launch daemon all at once (before MySQL 5.6.26, there was a MySQL startup item instead of a launch daemon, but Mac OS X 10.10 Yosemite removed support for startup items, hence the change).

Everything was going great, and I was excited to finally be back in operation… until I ran into one pesky little problem: I could not connect to my local MySQL server.

I immediately checked that MySQL was actually running, that I’d properly set my root password, and that my connection details were all correct. Then, after a bit of digging around in my Terminal, I found that the mysqld process was running on port 3307, not the usual default MySQL port of 3306.

Puzzled, I checked my my.cnf file. No port was specified there, so I manually added a directive to use port 3306, then restarted my MySQL server. Still no luck. For whatever reason, MySQL was hell-bent on using port 3307.

Now, I could have just gone with port 3307, as I was able to connect without issue once I knew to specify that port in my Sequel Pro connection details. However, I have somewhere around 100 sites on my local machine, and I would need to update the database configuration for every single one of them before I could work locally again (yes, I could probably have partially-automated the process of updating all of my configuration files with the new MySQL port 3307, but at this point, it was becoming a matter of personal pride).

What followed was a bit of a wild goose chase. My MySQL configuration file definitely specified port 3306, and I’d thoroughly checked to ensure that there wasn’t another configuration file taking precedence over it. I even uninstalled and reinstalled MySQL (more than once), but to no avail.

However, when I finally ran:

ps ax | grep mysql

I noticed that the output had port 3307 specified as a flag for the mysqld process:

 1105   ??  Ss     0:00.56 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/ --port=3307

Aha! This would seem to suggest that the port had been specified at runtime, and not in a configuration file at all. But how? Where?

The Solution

The answer, of course, had to be the MySQL launch daemon. It uses a plist definition found in the following file:


Sure enough, when I opened that file, I saw that the port was set as 3307:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
 <key>Label</key> <string></string>
 <key>ProcessType</key> <string>Interactive</string>
 <key>Disabled</key> <false/>
 <key>RunAtLoad</key> <true/>
 <key>KeepAlive</key> <true/>
 <key>SessionCreate</key> <true/>
 <key>LaunchOnlyOnce</key> <false/>
 <key>UserName</key> <string>_mysql</string>
 <key>GroupName</key> <string>_mysql</string>
 <key>ExitTimeOut</key> <integer>600</integer>
 <key>Program</key> <string>/usr/local/mysql/bin/mysqld</string>
 <key>WorkingDirectory</key> <string>/usr/local/mysql</string>

Emboldened by a new hope, I changed “3307” to “3306,” then restarted MySQL via the preference pane. Voila! It worked!

Now, I still don’t know why this plist definition was using port 3307 in the first place, which is still a bit frustrating (did I just get a wacky installation package?). But the good news is that I’m back in business, and, aside from a few new gray hairs, the damage was minimal. Hopefully, if anyone else out there runs into this rather strange issue, this post will help.