How to Add MySQL to PATH on Mac Using the Z Shell (zsh)

Open the .zshrc with vi (it also can be a text editor of you choice):

vi ~/.zshrc

The MySQL is probably in the following path:

/usr/local/mysql/bin

If it’s not you should find out where is and then continue with the tutorial.

Let’s say it is in the path I’ve suggested, then the next step is add the folloing to the .zshrc file we’ve opend not long ago:

export PATH=${PATH}:/usr/local/mysql/bin

Then run:

source ~/.zshrc

To make it work, and that’s it. Now you just have to use…

mysql -u root -p

To log in to MySQL and that’s all. Thanks a lot and I’m happy you’ve stopped by!