Python, Django and LAMPP

Disclaimer: the problem and the solution are not unique to LAMPP. If you have a MYSQL installation with uncommon paths, you will get a similar problem and you can solve it in a similar way. Just make sure you insert correct paths in the newly created .conf file for the LD (see below).

If, for whatever reason, you are running MySQL from your LAMPP installation and try to use Python's MySQLdb API to connect to MySQL server you will get the following nasty error into your face:

ImportError: libmysqlclient_r.so.15: cannot open shared object file

The problem is that lampp, in its attemt to not disturb the rest of the OS space, does not expose some crucial shared libraries (like: mysql client, ssl etc.) to Linux at large and Python is unable to find them even though they are installed under LAMPP.

The solution is quite easy (NO! Do NOT use LD_LIBRARY_PATH, that's evil). We need to tell LD to look for additional libraries.

For that, we need to create a lampp.conf file under /etc/ld.so.conf.d/ and insert following two lines in it:

/opt/lampp/lib/mysql
/opt/lampp/lib

When that's done, we tell LD to reload config by issuing:

sudo /sbin/ldconfig

Voila!

lampp and mysql client

I run lampp in ubuntu and when I try to run the mysql client I get this message:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Can I use the same solution as you used for you Python problem?

Googled for hours and your blog is the closest I found so far with a similar problem.

Different Problem

Dirk,

that does not look like the same problem, so you can not fix it with the described solution, but it looks like the problem in your case is that you are trying to connect with a "wrong" MySQL client. A mysql client was probably already present in the system and it's the first hit in the path. The LAMPP mysql client does not use "'/var/run/mysqld/mysqld.sock'" as a socks file.

Try running: "/opt/lampp/bin/mysql" instead of just "mysql" or put '/opt/lampp/bin' at the start of your PATH and lampp's mysql will be first hit.

You can also connect to lampp's MySQL server from the "other" mysql client, if you use TCP instead of socks. The way to do it is to run mysql with a specific host argument:

> mysql -h localhost

python - lampp issue

I face almost same problem

Iam a python Linux newbie Ubuntu 9.04 ,Python 2.6.2 standard install with MySQLdb module and mysql using lampp

when i try to connect mysql from python i get same exceptions

can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

from python as it tries to connect default mysql sock

will just setting PATH as you told will help?
or is there any other way to tell python that mysql is inside lampp?

Issue solution: Can't connect to local MySQL server...

i'm using XAMPP (LAMPP) for learning about Ruby on Rails. i was with the same problem (Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock') and then, after follow the explanation, dont had run done yet. The LAMPP create the same directory tree (in your form), with "bin", "etc", "var"... For make it up, you need to create the synbolic links:
# cd /opt/lampp/var/mysql
# ln -s mysql.sock mysqld.sock
# ln -s /opt/lampp/var/mysql /var/run/mysql

Best regards;

Werneck Costa

linux

awsome information