MW

How-To · Database

'mysql is not recognized as an internal or external command' — How to Fix on Windows (2026)

Windows can't find mysql.exe because its bin directory isn't in PATH. Here's the quickest fix, plus the careful version for when the quick fix doesn't take.

Jan 15, 2025 8 min read Windows beginner
Advertisement

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:

Command Prompt
C:\> mysql --version
'mysql' is not recognized as an internal or external command, operable program or batch file.

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:

Command Prompt — success
C:\> mysql --version
mysql Ver 8.0.32 for Win64 on x86_64 (MySQL Community Server - GPL)

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:

  1. Press Win + R to open the Run dialog
  2. Type sysdm.cpl and press Enter to open System Properties
  3. Click the Advanced tab
  4. Click Environment Variables at the bottom
  5. Under System Variables, scroll to find Path, select it, and click Edit
  6. Click New and add: C:\Program Files\MySQL\MySQL Server 8.0\bin (adjust the version number to match yours)
  7. Click OK on all dialogs to save
  8. Close and reopen your command prompt completely
  9. 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 like MySQL Server 8.0
  • Open it and check the bin folder
  • Confirm mysql.exe exists 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.

  1. Open System Properties — right-click “This PC” → Properties → Advanced system settings (or Win + Pause )
  2. Access Environment Variables — click the Environment Variables button. You’ll see two sections: User variables and System variables
  3. Edit PATH — under System variables, select Path and click Edit
  4. 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
  5. 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:

Environment Variables
Variable
Value
ComSpec
C:\WINDOWS\system32\cmd.exe
OneDriveConsumer
C:\Users\mahesh\OneDrive
Path
C:\Windows\system32;C:\Program Files\MySQL\MySQL Server 8.0\bin
PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.JS
TEMP
C:\Users\mahesh\AppData\Local\Temp
windir
C:\WINDOWS

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 ServerC:\Program Files\MySQL\MySQL Server X.X\bin
  • MySQL via XAMPPC:\xampp\mysql\bin (XAMPP typically adds this to PATH automatically)
  • MySQL via WAMPC:\wamp64\bin\mysql\mysqlX.X\bin (WAMP manages MySQL through its control panel)
  • MySQL via ChocolateyC:\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.msc and 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:

  1. Find your MySQL install (usually C:\Program Files\MySQL\MySQL Server X.X\bin)
  2. Add it to System PATH via Environment Variables
  3. Close and reopen your terminal
  4. Test with mysql --version

When everything is wired up correctly, you’ll see this:

Command Prompt — fixed
C:\> echo %PATH%
C:\Windows\system32;...;C:\Program Files\MySQL\MySQL Server 8.0\bin
C:\> mysql --version
mysql Ver 8.0.32 for Win64 on x86_64 (MySQL Community Server - GPL)
C:\> mysql -u root -p
Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \\g.

If you’re still stuck, switch to XAMPP or WAMP — they handle this entire problem for you.

MySQL Database Windows Troubleshooting PATH
Advertisement

Get weekly notes in your inbox

Practical tips, tutorials and resources. No spam.