First I found this helpful doc which got me part of the way there. Intention on that gist was only to be able to switch back and forth, not running simultaneously.
https://gist.github.com/ivanvermeyen/c2dfb8ad55a4fb699c5913a09422c1d9#cleanup
Basically;
* First wipe all mysql instances off
* Install the first mysql with homebrew
* Change the data dir to a version specific data dir
2 files to modify in /usr/local/Cellar/mysql@5.7/5.7.40
homebrew.mxcl.mysql@5.7.plist and
homebrew.mysql@5.7.service
change the data dir in both;
<string>/usr/local/var/mysql</string>
to something like
<string>/usr/local/var/mysql@5.7</string>
and rename /usr/local/var/mysql to /usr/local/var/mysql@5.7,
and there are a few other things you need to set specifically for each version in order to run more than 1 at the same time. It’s not quite enough to just change the port;
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql@5.7/bin/mysqld_safe</string>
<string>--datadir=/usr/local/var/mysql@5.7</string>
<string>--port=3307</string>
<string>--pid-file=pine-mysql57.makuch.org.pid</string>
<string>--log-error=pine-mysql57.makuch.org.err</string>
<string>--socket=/tmp/mysql57.sock</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql@5.7</string>
This page was helpful too https://dev.mysql.com/doc/refman/8.0/en/multiple-servers.html
Now you can start up this mysql and make sure it’s working.
One other thing to do is you must adjust your mysql client. I use the cli clients so what I did is to create a few bash functions;
$ cat .mysql_funcs.sh
mysql57() {
/usr/local/opt/mysql@5.7/bin/mysql --socket=/tmp/mysql57.sock $*
}
mysqldump57() {
/usr/local/opt/mysql@5.7/bin/mysqldump --socket=/tmp/mysql57.sock $*
}
mysql8() {
/usr/local/opt/mysql/bin/mysql --socket=/tmp/mysql8.sock $*
}
mysqldump8() {
/usr/local/opt/mysql/bin/mysqldump --socket=/tmp/mysql8.sock $*
}
Once you’ve done that for the first mysql version, repeat above for the 2nd version and change above config appropriately.
$ ls -ld /usr/local/Cellar/mysql* /usr/local/opt/mysql* /usr/local/var/mysql*
drwxr-xr-x 3 mkm admin 96 Aug 10 17:37 /usr/local/Cellar/mysql/
drwxr-xr-x 3 mkm admin 96 Aug 3 17:48 /usr/local/Cellar/mysql@5.7/
lrwxr-xr-x 1 mkm admin 22 Aug 10 17:37 /usr/local/opt/mysql -> ../Cellar/mysql/8.0.30
lrwxr-xr-x 1 mkm admin 26 Aug 3 17:48 /usr/local/opt/mysql@5.7 -> ../Cellar/mysql@5.7/5.7.38
lrwxr-xr-x 1 mkm admin 22 Aug 10 17:37 /usr/local/opt/mysql@8.0 -> ../Cellar/mysql/8.0.30
drwxr-xr-x 22 mkm wheel 704 Aug 10 18:30 /usr/local/var/mysql57/
drwxr-xr-x 48 mkm wheel 1536 Aug 10 18:32 /usr/local/var/mysql8/
$ ps -ef|grep sql | grep -v grep
501 78954 1 0 6:30PM ?? 0:00.02 /bin/sh /usr/local/opt/mysql@5.7/bin/mysqld_safe --datadir=/usr/local/var/mysql57 --port=3307 --pid-file=pine28-mysql57.makuch.org.pid --log-error=pine28-mysql57.makuch.org.err --socket=/tmp/mysql57.sock
501 79119 78954 0 6:30PM ?? 0:01.31 /usr/local/opt/mysql@5.7/bin/mysqld --basedir=/usr/local/opt/mysql@5.7 --datadir=/usr/local/var/mysql57 --plugin-dir=/usr/local/opt/mysql@5.7/lib/plugin --log-error=pine28-mysql57.makuch.org.err --pid-file=pine28-mysql57.makuch.org.pid --socket=/tmp/mysql57.sock --port=3307
501 79287 1 0 6:32PM ?? 0:00.02 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql8 --port=3308 --pid-file=pine28-mysql8.makuch.org.pid --log-error=pine28-mysql8.makuch.org.err --socket=/tmp/mysql8.sock
501 79451 79287 0 6:32PM ?? 0:11.07 /usr/local/opt/mysql/bin/mysqld --basedir=/usr/local/opt/mysql --datadir=/usr/local/var/mysql8 --plugin-dir=/usr/local/opt/mysql/lib/plugin --log-error=pine28-mysql8.makuch.org.err --pid-file=pine28-mysql8.makuch.org.pid --socket=/tmp/mysql8.sock --port=3308
$ . .mysql_funcs.sh
$ mysql57 <<< 'select version()'
version()
5.7.38
$ mysql8 <<< 'select version()'
version()
8.0.30
Enjoy || Ignore