doushan7997 2013-12-21 21:52
浏览 65
已采纳

与数据库Doctrine PDO连接

I am using Zend framework with Doctrine, and i am transfering from localhost to my server, but i receve this error. Everything is working well localy.

Warning: PDO::__construct() [pdo.--construct]: [2002] No such file or directory 
(trying to connect via unix:///tmp/mysql.sock) in /www/webvol19/94/yi8ghefpta7q527/
mywebsite.com/vendor/doctrine/Doctrine/DBAL/Driver/PDOConnection.php on line 36

My connection settings are these:

// pdo connection definition

'db' => array(
    'driver'         => 'Pdo',
    'dsn'            => 'mysql:dbname=dbname123;host=mysql410.ddd.com',
    'username' => 'user',
    'password' => 'pass121512',
    'driver_options' => array(
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
    ),
),

// doctrine connection definition
'doctrine_config' => array (
    'proxy_directory' => APP_PATH 
                         . DIRECTORY_SEPARATOR 
                         . 'data'
                         . DIRECTORY_SEPARATOR
                         . 'Doctrineproxy',
    'proxy_namespace' => 'Doctrineproxy',
    'doctrine_db_conn_params' => array (
        'driver'   => 'pdo_mysql',
        'user'     => 'user',
        'password' => 'pass121512',
        'dbname'   => 'dbname123',
    ),
    'is_dev_mode' => true,
),

i am not sure what is this before my website name

/www/webvol19/94/yi8ghefpta7q527/
  • 写回答

1条回答 默认 最新

  • dtcyv3985 2013-12-24 02:34
    关注

    You say that you transferring from localhost to your server but application still connects to localhost.

    Doctrine config include its own database parameters and independent from outside predefined database configuraiton. In your case you must to point host and (optionally) port inside 'doctrine_config':

    'doctrine_config' => array (
        ...
        'doctrine_db_conn_params' => array (
            'driver'   => 'pdo_mysql',
            'user'     => 'user',
            'password' => 'pass121512',
            'dbname'   => 'dbname123',
            /* add this */
            'host' => 'mysql410.ddd.com',
            //'port' => 3306
        ),
        ...
    ),
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭