Allow Your Applications To Access The XAMPP MySQL Server Directly

 1- Preliminary Note

- I'm using "Ojuba 2" Linux ("Fedora 10" based distribution).
- To work with this HowTo you have to be "root".
- You need you to stop your local MySQL database server (if you have a local version).

/etc/init.d/mysqld stop


2- What is the situation

If you want to have a full featured "LAMP" server with one step you can use "XAMPP", it's easy and fast but .......
You can't access its MySQL database server using the regular "mysql" client (/usr/bin/mysql), you have to use its own client (/opt/lampp/bin/mysql) to do that.


3- What is the problem

This was a problem for me, I have some databases in the server and some other scripts and applications need these databases and using the regular "mysql" client (/usr/bin/mysql) by default, and there is no option to change all these scripts and applications' code to point to the "XAMPP" client.


4- The first solution (short one)

Move the original "mysql" client (/usr/bin/mysql) to a backup copy.

mv /usr/bin/mysql /usr/bin/mysql.original

Then create a symbolic link to the "XAMPP" client (/opt/lampp/bin/mysql) in the original location like this:

ln -s  /opt/lampp/bin/mysql /usr/bin/mysql


5- The second solution (full solution)

The second solution to solve that problem is to work with the sock file directly, the sock points us to the database server, applications that want to access the database server are looking for that file to know how to access it.

XAMPP saves its sock file in this location:


But the regular applications will deal with the file in this location (if there is one):


To make all applications able to use the "XAMPP" database server we need to tell all these applications to deal with the "XAMPP" file, or simply we create a link from the "XAMPP" file into the regular file location, so every application that wants to access the database server will be forwarded to the "XAMPP" server.

We do this in one step:

ln -s /opt/lampp/var/mysql/mysql.sock /var/mysql/mysql.sock

After that all your applications should work as expected without problems. 


6- Thank you

Thank you for reading this and I hope to hear from you even in this site or directly on my site.

Share this page:

3 Comment(s)