Installing MySQL client without server on Mac

If, like me, you are using Docker or some other type of virtualization to provide a MySQL service for your Dev environment on a Mac, you will find that you do not have a MySQL client installed. You can’t download the client only from the MySQL Community Edition site (at least for Mac).

You have a couple of options, though.

  1. Install using Home Brew
  2. Install MySQLWorkBench

Since I wanted MySQL Workbench installed anyway, this seemed like the easiest solution for me.

Once MySQL Workbench is installed, you just need to add the path to the mysql binary to your path:

/Applications/MySQLWorkbench.app/Contents/MacOS

That’s it. Close your terminal, open it again, and you should be good to go. Note, using Docker, you will need to force a TCP/IP connection to your MySQL container:

mysql -u username -p -h 127.0.0.1

To make that easier, just create an alias in the .zshrc or .profile

alias mysql="mysql -h 127.0.0.1"

Restart your terminal or source your profile, and now you can run MySQL as usual:

mysql -u username -p