Access MySQL Command Line in XAMPP

Or XLMPP for that matter 😉

There are two ways to do it. Both are basically the same, but one just makes it a lot easier. We’ll go over the harder one first.

First Method:

Start the command prompt, and cd to the xampp directory. It’ll usually be something like:
cd ../../Program Files/xampp
if you used the installer and default install location.

Once in there, cd to the mysql bin directory.
cd mysql/bin

Now, run the command:
mysql.exe --user=root --password=
And the MySQL command line will start. If you’ve changed the username or password of the MySQL user, you need to change the –user= and –password= accordingly.

Second method:

Basically the same way as before, but we’ll create a batch file to make it easier.

First, create a file called mysql_command.bat in the XAMPP directory.

Edit this file with Notepad or any text editor, and paste in this:

@echo off

echo Starting MySQL command line...

mysql\bin\mysql.exe --user=root --password= 

pause

Save it, and change the –user= and –password= if you’ve changed the user or password.

Now, run mysql_command.bat and a command prompt will show up with the MySQL command line running.

It’s as easy as that.

34 Comments

  1. Thankyou so so much. I have spent all day trying to work this out. I’m absolutely rapped by the above information.
    Bianca

  2. Yes thank you, but you can also but the path to mysql.exe to your path variable start>settings>system>advanced>environmentvariables>system variable>path>edit and then add

    c:\pathToYourXampp\mysql\bin;

    to the end or the beginning of the string

    then click ok and ok.

    if you now start a new shell you may type “mysql -u yourUsername -p yourPassword(optional)”

    greets LeCross

  3. I’ve got a 64 bit processor and it says mysql.exe isn’t a valid win32 application. Is there another way of launching this in 64 bit mode or is there a 64-bit compiled version?

  4. Thanks a bunch!! Both solutions worked and I shall, of course, use the bat file on a routine basis.

  5. Thanks a mil-I’ve been trying to follow along in a few MySQL books and they show the command line syntax only-thanks for your help!

  6. Thanks a lot for your information!Great help!!!
    Both solutions do for me!
    Nice to know your site too 😀

  7. error 1045 coming… if i enter password thn olso n if i dun enter password then olso..wat to do..?/

  8. You can also add the path to the mysql.exe in your environment variables, that way windows CMD will recogniza the command “mysql”. just copy the path to the mysql/bin folder to the PATH environment variable of your PC and thats it