Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No database connection via doctrine in symfony

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?

like image 304
skanne Avatar asked Oct 01 '10 19:10

skanne


People also ask

Does Symfony use doctrine?

Symfony provides all the tools you need to use databases in your applications thanks to Doctrine, the best set of PHP libraries to work with databases. These tools support relational databases like MySQL and PostgreSQL and also NoSQL databases like MongoDB.

What is Doctrine query?

Doctrine Query Language (DQL) is an Object Query Language created for helping users in complex object retrieval. You should always consider using DQL (or raw SQL) when retrieving relational data efficiently (eg. when fetching users and their phonenumbers).

How Doctrine works?

Doctrine uses the Identity Map pattern to track objects. Whenever you fetch an object from the database, Doctrine will keep a reference to this object inside its UnitOfWork. The array holding all the entity references is two-levels deep and has the keys root entity name and id.

What is doctrine repository?

A repository in a term used by many ORMs (Object Relational Mappers), doctrine is just one of these. It means the place where our data can be accessed from, a repository of data. This is to distinguish it from a database as a repository does not care how its data is stored.


2 Answers

Or with MAMP

cd /var; sudo ln -s /Applications/MAMP/tmp/mysql mysql 
like image 107
Lithium Avatar answered Nov 11 '22 11:11

Lithium


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.

like image 33
Conrad Avatar answered Nov 11 '22 11:11

Conrad