HostOnNet Blog

Can’t connect to local MySQL server through socket

Looking for Linux Server Admin or WordPress Expert? We can help.

While running symfony jobeet tutorial, i got following error

fwh@pc11-desktop:~/web/jobeet$ php symfony doctrine:build-sql
>> doctrine  generating sql for models

                                                                                                                                                                                 
  While exporting model class 'JobeetAffiliate' to SQL: PDO Connection Error: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)  
                                                                                                                                                                                 

fwh@pc11-desktop:~/web/jobeet$

This is fixed by editing config/databases.yaml

Find line

dsn: 'mysql:host=localhost;dbname=jobeet'

Replace with

dsn: 'mysql:host=localhost;dbname=jobeet;unix_socket=/var/run/mysqld/mysqld.sock'

Posted in PHP

One Response to Can’t connect to local MySQL server through socket

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.