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.

12 Comments

  1. Bianca says:

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

  2. Renaud says:

    thanks for sharing!

  3. krizdus says:

    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

  4. Andy Piper says:

    Hey, this is great information, thanks. I just used it to help a friend who was stuck trying to work out how to get to the mysql command line in XAMPP (which I don't use myself).

    You might like to know that this information has been reposted on another blog, too:
    http://prajapatinilesh.wordpress.com/2008/01/21/access-mysql-command-line-in-xamppxlmpp/

  5. d3nd says:

    Thanks, it helps me alot :)

  6. Sean Maher says:

    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?

  7. martin says:

    thanx for the info! very useful article!

  8. Pierre says:

    Great info…
    Thanks

  9. Olivia says:

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

  10. steve says:

    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!

  11. Al says:

    Very helpful
    mysql -? |more gives some more options such as:
    mysql -h remotehostname

Leave a Reply