Reputation: 2303
I followed the symfony 2.1 cookbook page on using PDO for saving sessing data, on this link: http://symfony.com/doc/master/cookbook/configuration/pdo_session_storage.html the thing is, on my dev machine, everything works fine....also when i clear the cache for dev or prod enviorment but on my production machine (live server) i get the error:
[PDOException]
SQLSTATE[HY000] [2002] Can't connect to local MySQL server
through socket '/tmp/mysql.sock' (2)
when tring to clear cache with php app/console cache:clear --env=prod
so there seems to be something different between my live server and my dev machine,although the code in config.yml is the same.
i am using these settings under services:
pdo:
class: PDO
arguments:
- "mysql:dbname=%database_name%"
- %database_user%
- %database_password%
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
arguments: [@pdo, %pdo.db_options%]
and when i do ls -la /tmp/mysql.sock
i get
ls: cannot access /tmp/mysql.sock: No such file or directory
Upvotes: 0
Views: 866
Reputation: 1256
add this to your arguments in mysql:
services:
pdo:
class: PDO
arguments:
- "mysql:dbname=%database_name%;host=%database_host%"
- %database_user%
- %database_password%
calls:
- [setAttribute, [3, 2]] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
arguments: ["@pdo", "%pdo.db_options%"]
There's no database host on your configuration and the 1st parameter in the PDO class ($dsn) has two parameters seperated by a semicolon the dbname and dbhost, hope that will help, cheers!
Upvotes: 1