教义(在symfony项目中)无法通过套接字连接 [英] Doctrine (in symfony project) can not connect through socket

查看:84
本文介绍了教义(在symfony项目中)无法通过套接字连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将symfony项目放在客户端服务器上进行生产。
该网站在我们公司的服务器上运行良好,但现在出现此错误:

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)

这是数据库。yml:

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

此外,如果我尝试测试mysql_connect:

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();
?>

工作正常(显示 hello world)。
有人知道这是哪里来的吗?

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

非常感谢。

推荐答案

正如注释所建议的那样,就像在本地主机字符串前面被遗忘的 host =一样容易。要检查的另一件事是,有问题的mysql服务器实际上已配置为允许通过套接字进行连接,而不是使用端口3306(这是默认的TCP端口)。

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.

这篇关于教义(在symfony项目中)无法通过套接字连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆