Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to run the cake shell through xampp and I am running into some issues.

What works

  • I can connect PHP to Mysql while running through apache (in web browser)
  • I can run the PHP CLI in bash by typing php, I set up the bin folder under xampp as an environment variable
  • I can run cake, I set up the cake/console directory as an environment variable
  • I can run my shell scripts for cake without any models attached

What doesn't work

Running shell scripts when models are attached. I get the following error: PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /opt/lampp/htdocs/cakephp/cake/libs/model/datasources/dbo/dbo_mysql.php on line 561

What I tried

Originally, the cli was reporting that it couldn't find mysql_connect. So I installed php5-mysql despite my better judgement (I thought XAMPP would have already made the neccesary relationships). After I installed it, it was looking for mysql.sock. I tried changing the location under /etc/php5/cli/php.ini. Perhaps that is not the right location, or maybe I didn't change the correct variable.

Questions

Where can I change where the mysql.sock is located? Or, I am doing this incorrectly, is there a better way?

share|improve this question
add comment

2 Answers

So... my shortcut solution was:

sudo mkdir /var/run/mysqld
sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

It worked after that. I tried to copy /opt/lampp/etc/my.cnf to /etc/mysql/my.cnf, but that didn't change the error.

I hope this helps someone :)!

share|improve this answer
add comment

You should find where a my.cnf file is located for your setup, I guess it's somewhere under /opt/lampp/etc or something like this. This file has a [mysqld] section with socket=/path/to/mysql.sock parameter. You can use find /opt/lampp -name my.cnf to find the config file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.