Fix ‘MySQL command not found’ on Mac
November 6, 2023
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.
MySQL Isn't Installed
Before diving into the complexities, let's ensure that MySQL is indeed installed on your machine.
If there's no output, MySQL might not be installed.
Install MySQL using Homebrew:
MySQL isn't in your $PATH
Sometimes MySQL is installed, but the system can't find the binary because it's not in your
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.,
Or, if you've used Homebrew:
Then, source your shell configuration:
An alias could be pointing to a wrong or non-existent path for 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.
Corrupt MySQL Installation
It's possible your MySQL installation got corrupted, or there's some conflict with another package.
Uninstall and then reinstall MySQL:
For a manual installation, consult the MySQL documentation for uninstallation steps, and then reinstall.
Shell Specific Issues
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 (
Previous MySQL Versions
If you've had multiple versions of MySQL, there might be some path conflicts.
For Homebrew users:
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! 🚀
Not Equal in MySQL
How to Drop a User in MySQL
Duplicate Column Name in MySQL
Backticks in MySQL: An Overview
How to Set a Timer in MySQL
How to Fix the Illegal Mix of Collations Error in MySQL