I've got a vanilla install of XAMPP in OS X. How can I access the mysql command line tool? I've tried typing "mysql" at the command line, and it spits back "-bash: mysql: command not found".
5 Answers
XAMPP is installed in Mac OS X in the following directory:
/Applications/XAMPP/
You can look what's inside that directory and run mysql command line tool providing the full path to it:
$ /Applications/XAMPP/xamppfiles/bin/mysql
If you need, you can modify your PATH environment variable to include XAMPP binaries and you won't need to specify the whole path all the time.

- 176,835
- 32
- 241
- 292
Open your .profile file in Mac. This can be done by entering the terminal and typing
pico ~/.profile
Add the following line to your ./profile file. Replace 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
That is all, isn't easy!!

- 15,855
- 14
- 59
- 80

- 209
- 2
- 2
-
4After these steps you need logout or run 'source ~/.profile' command to reload your .profile file. – Capy Jun 14 '14 at 11:21
-
Together with Capy's comment - great answer! – Erik Kaju Nov 03 '14 at 15:33
-
I've tried all of the recommendation here, but still I got a "command not found: mysql" – Berlian Mar 01 '21 at 15:28
Open terminal and Follow this bellow step to add mysql to your mac environmental variable
step 1:
sudo nano ~/.bash_profile
step 2:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH
save it by control+x and then y and hit return. That's it!! now close the terminal and reopen
mysql --version
this will tell you which MySQL version you are using with xampp

- 6,015
- 5
- 27
- 24

- 73
- 1
- 3
-
this should be added ~/.profile rather than ~/.bash_profile as it is an enviromental variable and has nowt to do with bash. https://superuser.com/questions/789448/choosing-between-bashrc-profile-bash-profile-etc – Tristanisginger Jul 12 '19 at 10:55
Before using the mysql
command, make sure that you start up the server first by running
$ mysql.server start
Then you will be able to use the commands mysqladmin
and mysql
.
To shut it down, run
$ mysql.server stop
and to restart just use
$ mysql.server restart
Very intuitive.

- 134,834
- 32
- 188
- 245
-
1@tq, don't type the `$` -- that's a stand-in for the bash prompt – Chris Johnson Feb 19 '15 at 15:42
Since I cannot comment on the accepted answer by Pablo Santa Cruz - Here's some additional info. If you're going to modify your PATH environment variable to include XAMPP binaries, make sure you add
/Applications/XAMPP/xamppfiles/bin
and not
/Applications/XAMPP/xamppfiles/bin/mysql
to the /etc/paths file. To do this run the command
sudo nano /etc/paths
then add the path to the file. Save using Ctrl+O and exit using Ctrl+X. Quit terminal and open again.

- 31
- 5