How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Access MySQL from Command Line in XAMPP on Windows
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > OS > How to Access MySQL from Command Line in XAMPP on Windows
OS

How to Access MySQL from Command Line in XAMPP on Windows

how7o
By how7o
Last updated: May 22, 2026
7 Min Read
XAMPP MySQL command line on Windows — fixing 'mysql' not recognized
SHARE

If you’ve installed XAMPP on Windows and tried to run the xampp mysql command line tool from Command Prompt, you’ve probably seen this error:

Contents
  • TL;DR
  • Method 1 — cd into the MySQL bin folder
  • Method 2 — Add XAMPP MySQL to your Windows PATH
    • Open Environment Variables
    • Edit the Path variable
    • Open a NEW Command Prompt
  • Troubleshooting
    • “mysql” still not recognized after editing PATH
    • XAMPP installed somewhere other than C:\xampp
    • Access denied for user ‘root’@’localhost’
  • Frequently asked questions
  • Related guides
  • References
'mysql' is not recognized as an internal or external command,
operable program or batch file.

The cause is simple: Windows doesn’t know where mysql.exe lives because XAMPP doesn’t add it to your PATH. There are two ways to fix it — a quick fix for occasional use and a permanent fix for daily use. This guide walks through both, plus the "new cmd window" gotcha that catches almost everyone the first time.

Last verified: 2026-05-17 on XAMPP for Windows with MariaDB 10.4+. Originally published 2022-12-06, rewritten and updated 2026-05-17.

TL;DR

Either cd into C:\xampp\mysql\bin before running mysql, or add that folder to your Windows PATH so the command works from anywhere.

:: Quick fix: change directory then run
cd C:\xampp\mysql\bin
mysql -u root --password

:: Permanent fix: add C:\xampp\mysql\bin to System PATH
:: ...then in a NEW cmd window:
mysql -u root --password

Method 1 — cd into the MySQL bin folder

The fastest fix is to navigate to where mysql.exe lives before running the command. With the default XAMPP install path, that’s C:\xampp\mysql\bin.

cd C:\xampp\mysql\bin
mysql -u root --password

Press Enter at the password prompt — XAMPP installs MySQL with no password on the root account by default, so a blank password works out of the box. You should drop into the mysql> shell.

This works every time but is awkward if you use MySQL often: every new cmd window opens in your home directory, so you have to cd there again. For daily use, Method 2 is better.

Two ways to fix XAMPP MySQL not recognized on Windows: cd to the bin folder, or add it to PATH

Method 2 — Add XAMPP MySQL to your Windows PATH

Once C:\xampp\mysql\bin is in your PATH, the mysql command works from any folder in any cmd window. Three steps.

Open Environment Variables

Press the Windows key and type Environment Variables, then click Edit the system environment variables. In the System Properties window that opens, click the Environment Variables… button.

Edit the Path variable

In the lower section (“System variables”), select Path and click Edit. Click New and paste the XAMPP MySQL bin path:

C:\xampp\mysql\bin

Or, if you’d rather not hard-code the drive letter, use the %systemDrive% environment variable instead:

%systemDrive%\xampp\mysql\bin

Click OK on all three dialogs to save.

Open a NEW Command Prompt

This is where most people get stuck. PATH is read once when each cmd process starts, so any cmd window already open before the edit still uses the old value. Close those windows and open a fresh Command Prompt, then run:

mysql -u root --password

That should drop you into the MySQL shell from any folder.

Troubleshooting

“mysql” still not recognized after editing PATH

Confirm you opened a new cmd window after saving the change. To verify PATH actually contains the bin folder, run echo %PATH% in the new window and look for xampp\mysql\bin in the output. If it’s missing, re-do Method 2 — it’s easy to add the entry under “User variables” when you meant “System variables” (both work, but only within their own scope).

XAMPP installed somewhere other than C:\xampp

Replace C:\xampp with your actual install path everywhere it appears. The MySQL bin folder will sit inside that. For example, if XAMPP lives at D:\dev\xampp, use D:\dev\xampp\mysql\bin. The XAMPP Control Panel displays the install path in its title bar.

Access denied for user ‘root’@’localhost’

This is a different problem — MySQL is reachable but the credentials don’t match. XAMPP installs MySQL with an empty root password by default, so press Enter at the prompt. If you’ve run XAMPP’s security script and set a password, pass it after --password=:

mysql -u root --password=yourpassword

Frequently asked questions

Why does Windows say 'mysql' is not recognized as an internal or external command?

Because the mysql.exe binary that ships with XAMPP lives at C:\xampp\mysql\bin, but Windows doesn’t add that folder to your PATH automatically. When you type mysql in Command Prompt, Windows scans every directory listed in PATH and can’t find the executable, so it reports the binary as missing. Two fixes work: cd into the bin folder first, or add it to PATH permanently.

Where is the XAMPP MySQL bin folder?

With XAMPP’s default Windows install path it’s C:\xampp\mysql\bin. If you installed XAMPP to a different drive or folder, look for the mysql\bin subfolder inside your XAMPP install directory — the XAMPP Control Panel shows the install path in its title bar.

Do I need to restart Windows after editing PATH?

No — just close and reopen Command Prompt. PATH is read when each cmd.exe process starts, so windows already open before the edit will keep using the old value. A fresh cmd window picks up the new PATH immediately, without a reboot.

What’s the default XAMPP MySQL root password?

Empty. Press Enter at the password prompt, or use mysql -u root --password= with nothing after the equals sign. If you’ve run XAMPP’s security script (setup_xampp.bat or the web-based XAMPP Security wizard) and set a password there, use that password instead.

Can I use HeidiSQL or MySQL Workbench instead of the command line?

Yes. XAMPP also ships HeidiSQL on Windows, and you can install MySQL Workbench separately — both provide a GUI for browsing tables and running queries. The command-line client is still useful for scripting, quick one-off queries, and remote sessions where you only have SSH access.

Related guides

  • How to Export and Import All MySQL Databases at Once
  • How to Check Which MySQL Database Is Using the Most CPU
  • How to Create Users and Grant Privileges in MySQL 8 on Ubuntu

References

MySQL mysql client docs: dev.mysql.com/doc/refman/8.0/en/mysql.html. Windows environment variables reference: learn.microsoft.com/en-us/windows/win32/procthread/environment-variables.

TAGGED:mariadbmysqltroubleshootingwindowsxampp

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article aaPanel MySQL root password reset via the Databases page How to Reset the MySQL Root Password in aaPanel
Next Article Pure-FTPd add user command line — pure-pw useradd flow on Linux How to Add a User to Pure-FTPd from the Command Line on Linux
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Run Laravel queue workers with Supervisor
How to Run Laravel Queue Workers in Production with Supervisor
May 23, 2026
Nginx as a reverse proxy for a Node.js app on Ubuntu
How to Set Up Nginx as a Reverse Proxy for Node.js on Ubuntu
May 23, 2026
Install and configure Redis on Ubuntu for Laravel and WordPress
How to Install and Configure Redis on Ubuntu (for Laravel & WordPress)
May 23, 2026
Harden a fresh Ubuntu VPS with UFW, Fail2Ban, and SSH key auth
How to Harden a Fresh Ubuntu VPS: UFW + Fail2Ban + SSH Key Auth
May 23, 2026
Set up Let's Encrypt SSL with Certbot on Ubuntu
How to Set Up Let’s Encrypt SSL with Certbot on Ubuntu (Apache & Nginx)
May 23, 2026

You Might Also Like

Fix Ubuntu terminal not opening on VirtualBox
OS

Fix: Terminal Won’t Open in Ubuntu on VirtualBox

4 Min Read
Safely remove MySQL binary log files to free disk space
Server Management

How to Safely Clean Up MySQL Binary Log Files

5 Min Read
cd to a different drive in Windows — D: vs cd /d D:path
OS

How to cd to a Different Drive in Windows

4 Min Read
Install Composer on Ubuntu — terminal with composer-setup.php and PHP elephant icon
Web Development

How to Install Composer on Ubuntu: Step-by-Step Guide

8 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?