If you’re seeing the error “mysql is not recognized as an internal or external command” on Windows, you’re not alone. It happens because Windows can’t find the MySQL executable in your system’s PATH environment variable.
Here’s exactly what it looks like:
This guide walks through the quick fix, the careful version, and the troubleshooting steps for when both fail. By the end your terminal should look like this instead:
Understanding the error
When you type mysql in your command prompt, Windows searches every directory listed in PATH. If MySQL’s bin directory isn’t in that list, Windows doesn’t know where to find mysql.exe — hence the error.
The MySQL installer usually adds the right path automatically, but that fails when you:
- Installed MySQL manually
- Moved MySQL to a different location after installation
- Have multiple MySQL installations
- Installed MySQL as a service without the command-line tools
Quick fix: add MySQL to PATH
The most common solution is to add MySQL’s bin directory to your Windows PATH:
- Press Win + R to open the Run dialog
- Type
sysdm.cpland press Enter to open System Properties - Click the Advanced tab
- Click Environment Variables at the bottom
- Under System Variables, scroll to find Path, select it, and click Edit
- Click New and add:
C:\Program Files\MySQL\MySQL Server 8.0\bin(adjust the version number to match yours) - Click OK on all dialogs to save
- Close and reopen your command prompt completely
- Test with
mysql --version
If mysql --version now prints the version, you’re done. If you still see the error, continue below.
Verify the installation
Before troubleshooting PATH, confirm MySQL is actually installed:
- Look in
C:\Program Files\MySQL\for a folder likeMySQL Server 8.0 - Open it and check the
binfolder - Confirm
mysql.exeexists inside - If not installed, download MySQL from mysql.com/downloads and tick “Add to PATH” during install
Common alternative install locations:
C:\mysql\C:\Program Files (x86)\MySQL\- A custom directory you chose during setup
Detailed PATH setup
If the quick fix didn’t take, walk the careful version.
Method 1: System Properties (recommended)
- Open System Properties — right-click “This PC” → Properties → Advanced system settings (or Win + Pause )
- Access Environment Variables — click the Environment Variables button. You’ll see two sections: User variables and System variables
- Edit PATH — under System variables, select Path and click Edit
- Add MySQL — click New and enter the full path, e.g.
C:\Program Files\MySQL\MySQL Server 8.0\bin. Use backslashes, no trailing backslash - Apply — OK through all dialogs, then close and restart your terminal. Test with
mysql --version
Here’s what the Environment Variables dialog should look like after you add the MySQL path — the highlighted row is the one you’re creating:
Method 2: Command line (advanced)
PowerShell as Administrator:
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", "Machine") + ";C:\Program Files\MySQL\MySQL Server 8.0\bin",
"Machine"
)
Command Prompt as Administrator:
setx /M PATH "%PATH%;C:\Program Files\MySQL\MySQL Server 8.0\bin"
The /M flag sets the system variable — requires admin rights. Replace the path with your actual install path. Close and reopen your terminal after.
Alternative: use the full path
If you don’t want to touch PATH (or need a temporary workaround), invoke MySQL with its full path:
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -u root -p
Or create a tiny batch wrapper in a directory that’s already in PATH (like C:\Windows\):
@echo off
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" %*
Save as mysql.bat. You can now call mysql from anywhere.
Different MySQL versions and paths
MySQL can be installed several ways, each with its own path:
- MySQL Community Server —
C:\Program Files\MySQL\MySQL Server X.X\bin - MySQL via XAMPP —
C:\xampp\mysql\bin(XAMPP typically adds this to PATH automatically) - MySQL via WAMP —
C:\wamp64\bin\mysql\mysqlX.X\bin(WAMP manages MySQL through its control panel) - MySQL via Chocolatey —
C:\ProgramData\chocolatey\lib\mysql\tools\mysql-X.X\bin - Portable MySQL — wherever you extracted it, e.g.
C:\mysql-portable\bin(you’ll add this to PATH manually)
Troubleshooting
If MySQL still isn’t recognized after the steps above, work through these:
- Restart your computer — some systems require a full restart, not just a terminal restart
- Check the MySQL service is running — open
services.mscand look for a MySQL entry - Verify the path matches exactly what you added to PATH
- Try MySQL Command Line Client from the Start Menu — if it works there, PATH is your only issue
- Check for multiple installations that might be conflicting
- Confirm you edited the System PATH, not just User PATH
- Close and reopen the terminal completely — a new tab in an old terminal won’t pick up new PATH
PATH changes not taking effect
Print the current PATH to verify:
echo %PATH%
If your MySQL path isn’t in the output, the change didn’t save. Re-do the edit and confirm. Some systems also need a full Windows restart for PATH changes to propagate to all services.
MySQL works in some terminals but not others
Different terminals load PATH differently. Command Prompt, PowerShell, Git Bash, and the VS Code integrated terminal each cache PATH at start. The fix is always: close every terminal window and reopen.
For local development: XAMPP / WAMP
If you only need MySQL for local development, a packaged stack handles PATH automatically.
XAMPP (cross-platform) includes MySQL, Apache, PHP, phpMyAdmin in one installer. Download from apachefriends.org, install, start MySQL from the XAMPP Control Panel, and the command line is available without touching PATH yourself.
WAMP (Windows-specific) is similar — download from wampserver.com, install, and run from the system tray.
Use standalone MySQL when you need a specific version, a production-like setup, or fine-grained configuration. Use a stack solution when you want to stop fighting installation.
Conclusion
Fixing this error is straightforward once you understand how Windows PATH works. The reliable solution:
- Find your MySQL install (usually
C:\Program Files\MySQL\MySQL Server X.X\bin) - Add it to System PATH via Environment Variables
- Close and reopen your terminal
- Test with
mysql --version
When everything is wired up correctly, you’ll see this:
If you’re still stuck, switch to XAMPP or WAMP — they handle this entire problem for you.