Category Archives: MacOS

Getting the MySQL command on MacOS (v 10.11 and up)

If you are familiar with using the terminal on Linux, the absence of the mysql command can at times feel painful for a Mac user. While launching MySQLWorkbench is easy enough, sometimes those of us familiar with *nix shells just want to use the terminal. I spent an hour or so searching for a solution, with only MySQL server or outdated homebrew formulae to be found. Then, I realized something that should have been obvious all along.

If you have MySQLWorkbench installed on your computer, it must have some way to communicate with a MySQL server, and my money was on—wait for it—the mysql command.

Here’s how I got it back (Note: This method requires MySQLWorkBench)

First, I did a search for the path.

sudo find / -name mysql -print -quit

Then, I copied that path (in my case it was /Applications/

Finally, I put that path into my .bashrc file.

printf "alias mysql='Applications/'" >> ~/.bashrc

I repeated the same for mysqldump.

Altogether Now

If you’re looking for an easy few lines to copy it, here goes:

printf "\nalias mysql='$(sudo find / -name mysql -print -quit)'\nalias mysqldump='$(sudo find / -name mysqldump -print -quit)'" >> ~/.bashrc

If you’re running VVV, you can easily test your connection like so:

mysql -h -u external -p

 # (password is external)

If you are not running VVV, that’s fine – just substitute the hostname, username, and password as needed.