9

I'm working on the symfony tutorial jobeet and I have problems to get a database connection to the MySQL-database via doctrine. Development enviroment: Mac OS X and XAMPP.

The command php symfony doctrine:build-schema gives me the following error message:

Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/xx/projects/myproject/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 470
PDO Connection Error: SQLSTATE[HY000] [2002] No such file or directory

The database settings in the database.yml:

 all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=my_project_db'
      username: root
      password: root

MySQl is running. Username and password are correct. The database 'my_project_db' exists.

Could anybody give me a hint what's going wrong?

2
  • Does the /var/mysql/mysql.sock file exist? Try finding that file using locate if not. Commented Oct 1, 2010 at 19:50
  • yes. it's an empty file in /Applications/XAMPP/xamppfiles/var/mysql/ Commented Oct 1, 2010 at 19:59

5 Answers 5

14

Try to create a symlink in /var/mysql to your mysql.sock:

sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql /var/mysql
Sign up to request clarification or add additional context in comments.

1 Comment

sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql /var/mysql
13

Or with MAMP

cd /var; sudo ln -s /Applications/MAMP/tmp/mysql mysql 

Comments

3

On Mac OSX Lion:

cd /var;
sudo mkdir mysql; cd mysql;
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock

Comments

3

I had the same problem on my apple mac and did the following:

cd /var; sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/ mysql

Worked for me.

Comments

1

This situation also happened to me and I use MAMP Pro. If you use MAMP Pro, its worth checking the main window. Look at "MySQL" tab, and then see "Allow local access only" checkbox. If it is checked, you should uncheck it. Finally, click, "Apply" button.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.