简体   繁体   English

如何使用 Doctrine 1.2 连接到 MySQL 插座?

[英]How do I Connect to MySQL socket using Doctrine 1.2?

Following the directions at http://www.doctrine-project.org/projects/orm/1.2/docs/manual/introduction-to-connections/en#dsn,-the-data-source-name:examples , I get the following error按照http://www.doctrine-project.org/projects/orm/1.2/docs/manual/introduction-to-connections/en#dsn,-the-data-source-name:examples的指示,我得到了跟随错误

Message: PDO Connection Error: SQLSTATE[HY000] [2005] Unknown MySQL server host 'unix(' (1) 

The exact DSN I am using is "mysql://root@unix(/tmp/mysql.sock)/test" Yes, root with no password via local unix socket.我使用的确切 DSN 是“mysql://root@unix(/tmp/mysql.sock)/test”是的,通过本地 unix 套接字没有密码的 root。

This exact configuration works with phpMyAdmin, so I know the settings are valid.这个确切的配置适用于 phpMyAdmin,所以我知道这些设置是有效的。 I've also tried with another user with password and got the same error.我也尝试过使用另一个密码的用户并得到同样的错误。

What confuses me is why it's throwing the error about the host, when I'm trying connect via socket as the instructions provided.让我感到困惑的是,当我按照提供的说明尝试通过套接字连接时,为什么它会抛出有关主机的错误。

Doctrine needs PDO-like query string, see if it matches yours: Doctrine 需要类似 PDO 的查询字符串,看看它是否与您的匹配:

http://www.php.net/manual/en/pdo.construct.php http://www.php.net/manual/en/pdo.construct.php

Moreover, have a look at this:此外,看看这个:

Doctrine (in symfony project) can not connect through socket Doctrine(在symfony项目中)无法通过socket连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM