Doctrine (in symfony project) can not connect through socket

最后都变了- 提交于 2019-12-11 05:38:57

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/1916012/doctrine-in-symfony-project-can-not-connect-through-socket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!