views:

312

answers:

1

Hi guys !

I am trying to put a symfony project on a client server for production. The website worked fine on our company's server, but now i have this error :

500 | Internal Server Error | Doctrine_Connection_Exception
PDO Connection Error: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Here is the database.yml :

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=24DLJLRR1'
      username: xxxxxxxxxx
      password: xxxxxxxxxx

And moreover if i try to test a mysql_connect :

<?php
  mysql_connect("localhost", "xxxxxxxxxx", "xxxxxxxxxx"); 
  mysql_select_db("24DLJLRR1"); 
  $answer = mysql_query("SELECT * FROM video_games") or die(mysql_error());
  echo 'hello world'
  mysql_close();
?>

It works fine (it displays the 'hello world'). Someone knows where this come from ?

Thank you very much.

+2  A: 

As the comment suggests it may be as easy as a forgotten "host=" right in front of the localhost string. Another thing to check for is that the mysql server in questions actually is configured to allow connections over the socket as opposed to using port 3306 which is the default TCP port.

Knut Haugen
Yes, thank you ! I might have lost it while i was making some changes.But it still doesn't work (same error).The server has to be configured for socket connections ?It is my customer's host (it's quite a lame host...) and i don't know how to check this. Could you help ?Does it have something to do with the PDO connections ? Because they told me they should work.
Julien
There are two settings in the mysql config file, socket and port respectively. You can run both or just one of them. One way to check is by using the mysql command line client and specifying --protocol=SOCKET for testing that the socket works.
Knut Haugen
Thank's.I am not sure I can access to the mysql command line client since it's a shared hosting provided by a hosting company. Can I ?If yes how ? If not, am I fucked ?
Julien
Ok, thanks to your help I could explain the problem to the technical service and it's an problem of the server, they are fixing it.Thanks a lot.
Julien