Page 1 of 1

Can't connect to socket [Solved]

PostPosted: 14. March 2012 10:59
by akhasis

I know this topic has ben discussed many times before, but I've followed the advice in previous related posts with no success.

I'm trying to run a php script via cron, i.e., in a terminal. When I run it, I get the following error:

Can't connect to local MYSQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /opt/lampp/htdocs/applicationfolder/script.php on line X

Since I'm not authorized to make big changes in the system, I have only tried to solve the issue by editing some values in the my.cnf, as suggested in some posts in this same forum and other related ones:

We just have to modify the socket parameter on our my.cnf with the right path to the XAMPP socket:

bdispatcher@tatil02:/opt/lampp$ sudo find /opt/lampp/ -iname "*.sock*"

It happens that I have 3 my.cnf files in my system, and since I am not very experienced in Ubuntu, I don't know which one to change, so I changed all of them:


I also don't know if they all are necessary and I may even have created some of them following some blog instructions to solve my problem. But as I said my ubuntu level is so low that I can't remember which one or why.

Ubuntu 9.04, xampp 7.1.1

Thank you in advance for any help you can provide me!

Re: Can't connect to socket [Solved]

PostPosted: 14. March 2012 14:08
by akhasis
Ok, found the error. It was all my mistake.

As I read on other posts, there are two simultaneous instalations of php on my Ubuntu. The thing is, I was trying to launch my script with the wrong PHP (the one that was installed before xampp) like this:

/usr/bin/php /opt/lampp/htdocs/applicationfolder/script.php

When it should be launched with the xampp PHP, like this:

/opt/lampp/bin/php /opt/lampp/htdocs/applicationfolder/script.php

Hope this helps someone, since I've spent 3 days looking for an answer with no luck :D