MySQL Service on Mac - Changing the Port

Contains tips for configurators working with Aware IM
Post Reply
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

MySQL Service on Mac - Changing the Port

Post by PointsWell »

So I spent the better part of a day trying to change the default port on mySQL on my desktop. Why? I have a remote server that AIM runs off and I can connect to by an SQL proxy (thereby keeping my database without an external IP address).

I also keep some 'useful' data locally but could not maintain a connection to the cloud and my local DB as they are both by default running off port 3306.

I wasted the better part of a day trying to figure out how to change the port (the my.cnf file is ignored when mySQL runs as a service).

The LaunchDaemon folder

Code: Select all

/Library/LaunchDaemons 
Contains a file

Code: Select all

com.oracle.oss.mysql.mysqld.plist
All advice online points to editing this to add a program parameter of

Code: Select all

--port=3307
(or whatever port you want to use).

What none of the online advice mentions is that the plist file will try to launch with Xcode which will break the plist file.

Instead, what is required is that you first run

Code: Select all

sudo plutil -convert xml1 com.oracle.oss.mysql.mysqld.plist
before using nano or vi to edit the file.

You can then update the ProgramArguments key to look something like this:

Code: Select all

<key>ProgramArguments</key>
	<array>
		<string>/usr/local/mysql/bin/mysqld</string>
		<string>--user=_mysql</string>
		<string>--basedir=/usr/local/mysql</string>
		<string>--datadir=/usr/local/mysql/data</string>
		<string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
		<string>--port=3307</string>
		<string>--log-error=/usr/local/mysql/data/mysqld.local.err</string>
		<string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string>
		<string>--keyring-file-data=/usr/local/mysql/keyring/keyring</string>
		<string>--early-plugin-load=keyring_file=keyring_file.so</string>
	</array>
That was the least inspiring day of my month so far...
Post Reply