Multiple MySQL Versions with Homebrew
CONTENT
For homebrew version 2.1.2
1 |
|
Install the current version of mysql.
1 |
|
Install the older version of mysql.
1 |
|
Then to switch to the older version.
1 |
|
And to switch back to the current version.
1 |
|
To verify which mysql version you’re on at any time.
1 |
|
And to unload a mysql agent for a given version.
1 |
|
Caution
jpmelguizo:
Went with mysql@5.6 and I’m getting:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Although brew services list says mysql@5.6 is started, there’s no mysqld process running and no mysql.sock file anywhere. Any ideas on how to fix it? should I just go with the deprecated mysql56 instead?
jsweeney:
(NOTICE: If you see
\@
, it is just@
, remove the backslash(\
) when you copy.)
I also had your problem. My issue was that the mysql@5.6 was trying to boot the mysql 5.7 database (installed in the default/usr/local/var
folder). If you want to run both in parallel on their own distinct databases, there are a few more steps to do.
- Create a new (separate) data directory and database for the 5.6 version
Run/usr/local/Cellar/mysql\@5.6/5.6.36/bin/mysql_install_db --user=root --datadir=/usr/local/var/mysql56
- Change the configuration to start the 5.6 version pointing to this database
Edit/usr/local/Cellar/mysql\@5.6/5.6.36/homebrew.mxcl.mysql\@5.6.plist
to change both/usr/local/var/mysql
instances to/usr/local/var/mysql56
(I didn’t put the@
in the folder name just in case it would cause issues).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql@5.6</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql@5.6/bin/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
<string>--datadir=/usr/local/var/mysql56</string> <!-- <<<<<<<<<<<<<<<<<< HERE -->
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql56</string> <!-- <<<<<<<<<<<<<<<<<< AND HERE -->
</dict>
</plist>- Change the port of the 5.6 server - if ever you want to start both at the same time.
Edit/usr/local/Cellar/mysql\@5.6/5.6.36/my.cnf
, uncommentport
and change it to some other value than3306
.NOTE A little caveat about connecting to the MySQL instances after such a setup. Using any kind of driver will > work out of the box if you set the correct port. However, at the command line,
1
2
3
4
5
6
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
port = 3356
# server_id = .....
# socket = .....mysql
ignores the--port
> value by default, so you need something like this>See this article for more details: https://dev.mysql.com/doc/refman/5.7/en/connecting.html
1mysql -uroot --port=3356 --protocol=TCP
mysql_downgrade:
1 |
|
via:
from: https://gist.github.com/benlinton/d24471729ed6c2ace731
mysql_downgrade: https://gist.github.com/6temes/3c52f8a472f61d9676e7218a98812286