XAMPP MySQL Command Line

Published on Tuesday 2, April 2013

MySQL command line allows you to manage your database environment through your terminal, or command prompt for Windows. Typically when you set up a web server you would have installed MySQL as its own service and can easily access the MySQL command line via mysql (mysql.exe). However in a development situation you may have used XAMPP which bundles it all together for you and you can't just access the XAMPP MySQL command line through a registered path.

Accessing XAMPP MySQL via command line.

In order to access MySQL via command line you have to navigate to XAMPP's files directory and locate the bin or executable. Here is how you can quickly access the XAMPP MySQL command line (assuming you didn't change default installation paths, of course) :

Mac

cd /Applications/XAMPP/xamppfiles/bin;./mysql --user=root --password=

Windows

cd ../../Program Files/xampp/mysql/bin/mysql.exe --user=root --password=

Linux

/opt/lampp/bin/mysql --user=root --password= 

​Please correct me if wrong gathered the Windows and Linux commands through a quick Google search. Be sure to utilize shortcuts - I have an alias set up in my bash_profile so I just have to type in mysql to get into my XAMPP MySQL command line. If you have never setup a bash_profile enter open ~/.bash_profile into the terminal and you can modify bash aliases here.

alias mysql='cd /Applications/XAMPP/xamppfiles/bin; ./mysql --user=root --password=XXXX'