For the impatient:
How to setup the mysql command line after installing Xampp in Mac OS X:
-
Open your .profile file in Mac. This can be done by entering the terminal and typing
open -t ~/.profile
-
Add the following line to your ./profile file. Replace the bolded part with the path where you installed Xampp, however by default this is the route and should work:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH
-
Open a new terminal window (Recommendation is to quit all terminal windows and then reopen) and type:
mysql
Thats it! Enjoy geeks!
For the people who have a little bit more time to learn what actually happened, here is the explanation.
When you install Xampp on Mac OS X it does come with mysql, however you may not access it from the command line by just typing the mysql command since the terminal does not know where to find the executable file.
In case you did not know, these type of knowledge of where to find files is given to the terminal through your profile file. In this file you will be able to export paths to your global $PATH variable that contains all the routes where your terminal will look into when receiving a command.
You may or may not have your profile file. It is tricky because if you are in Mac OS X Lion you will not see it. Hence, to find your profile file you will have to create it as I explained in a previous post.
The first instruction
open -t ~/.profile
Will either open or create your profile file. It will use the texteditor built in Mac which will be more confortable for this task than using vi or any other editor. If you have TextMate you may replace the open -t with mate command instead. The ~ will setup yourself in your home directory and the /.profile will give the route to the file which will be opened or created.
After this is done and with the command
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH
you are exporting the path where Xampp keeps the command files, including those to run the mysql command line, into the $PATH variable. Therefore, when you type mysql in your terminal window, it will also search for this location for the command.
If you do not want to modify your $PATH variable, you would need to write all the full route plus the command in order to access the mysql command line. This means you would need to write:
/Applications/xampp/xamppfiles/bin/mysql
Every single time that you want to run the mysql command line from the terminal.
After doing this steps it is recommended to close and restart the terminal. Sometimes the changes will not take effect and this will make you think that you did the process wrong. However, if you restart the terminal and type the mysql, you will be able to access the command line.
I hope this was useful.
Enjoy,
Andrés Díaz



This worked for me! Thanks so much ;O)
Simple but effective =) I am glad it worked for you Zaferina! What are you using Xampp for nowadays?
Simple but effective =) I am glad it worked for you Zaferina! What are you using Xampp for nowadays?
Andi, this has not worked for me because I had already installed MySQL stand alone.
So, I look around and I found an easier way to do it…
Modify the paths file. For this, open a Terminal and type:
sudo vi /etc/paths
Add the line:
/Applications/xampp/xamppfiles/bin
Save the file. You will be prompted to enter your password. Do it. Now, close all your opened terminals (use CMD+Q).
Open a new terminal, and that’s it!
Im in an iBook G4 with Tiger OS X, and I make it with the following command in the modification or creation of the .profile file:
pico ~/.bash_profile
in the file I wrote the line that Andres gave us:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATHand then i just save the file. As Andres said, I had to close all terminal windows (Cmd÷Q) and just open a new terminal window and Type ‘mysql’ !And that’s all.
great guide – any idea how to do it in linux(opt/lampp/mysql -u *** -p ***)??
i will be glad if you send my a quick instruction
(refaelgold26gmail.com)
happy programming,
refael gold
greate thanks.. thats a usefull help
You are welcome =)
Thanks a million!
Yeah man, I am glad. I still use this because I constantly forget and cannot access mysql from the terminal.