Downgrade MySQL client version in MacOS

Goal

Downgrade MySQL client version in MacOS

Description

Before going into the details of this recipe, I know that there may be better options to use MySQL, such as Docker containers. Explaining the best way to have different tools running on a developer’s machine is not really the focus of the recipe. Instead, it focuses on the case of someone that has a version of MySQL installed on a MacOS system where that system installed the latest version of the client, say, version 9, but there is still the need to use the previous version for compatibility reasons with what’s running in production, for example.

How to

The following set of commands explains what I had to do recently in order to revert MySQL client version 9 being installed to version 8. In the first ones, I’ll simply install version 8 of MySQL and I’ll try to unlink the previous version of MySQL and link it to the installed version.

> brew install [email protected]
> brew unlink mysql (it may fail)
> brew link [email protected]

Unfortunately, the unlink/link step did not succeed and I also had to execute the following (I also tried the --force flag, but I failed to succeed. The following commands, remove the symbolic link mysql-client in /opt/homebrew/opt/ and adds a new one pointing to the recently installed version 8.4 /opt/homebrew/Cellar/[email protected]/8.4.2:

> rm /opt/homebrew/opt/mysql-client
> ln -sv /opt/homebrew/Cellar/[email protected]/8.4.2 /opt/homebrew/opt/mysql-client

With the previous (ensure you have the same path that I’ve linked above), I was finally able to use the version 8 of MySQL and no longer have version 9, as proved with the command below:

> mysql --version
mysql Ver 8.4.2 for macos14.4 on arm64 (Homebrew)

Explanation

No explanations are necessary for this recipe, as all was explained inline.

Leave a comment

Design a site like this with WordPress.com
Get started