简体   繁体   中英

Connection with database 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/

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
    ),
    ...
),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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