Fix ‘MySQL command not found’ on Mac
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Hitting the “command not found” wall when trying to use MySQL on macOS? You’re not alone. Let’s tackle the most common reasons and get you back on track.
Before diving into the complexities, let’s ensure that MySQL is indeed installed on your machine.
which mysql
If there’s no output, MySQL might not be installed.
Install MySQL using Homebrew:
brew install mysql
Sometimes MySQL is installed, but the system can’t find the binary because it’s not in your $PATH.
echo $PATH
You should see a path related to MySQL, typically /usr/local/mysql/bin for a manual installation or /usr/local/bin for a Homebrew installation.
Update your shell configuration file (e.g., .bashrc, .bash_profile, or .zshrc) with:
export PATH="/usr/local/mysql/bin:$PATH"
Or, if you’ve used Homebrew:
export PATH="/usr/local/bin:$PATH"
Then, source your shell configuration:
source ~/.bashrc
An alias could be pointing to a wrong or non-existent path for MySQL.
For Bash:
alias | grep mysql
For Zsh:
alias -L | grep mysql
If there’s a problematic alias, remove or correct it in your shell configuration file. Then, reload your shell config as in the previous step.
It’s possible your MySQL installation got corrupted, or there’s some conflict with another package.
Uninstall and then reinstall MySQL:
For Homebrew:
brew uninstall mysql
brew install mysql
For a manual installation, consult the MySQL documentation for uninstallation steps, and then reinstall.
If you switched to a new shell (e.g., from Bash to Zsh), there might be differences in how paths and aliases are set up.
Ensure you’ve updated the correct configuration file for your active shell (.bashrc, .bash_profile, or .zshrc).
If you’ve had multiple versions of MySQL, there might be some path conflicts.
For Homebrew users:
brew cleanup
For others, ensure you’ve removed old MySQL installations and only have the one you intend to use.
If you’ve walked through all these steps and are still encountering issues, it might be a more complex system-specific problem. Consider reaching out to relevant forums or communities with specifics for more tailored help.
Happy querying! 🚀
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.