debugsqlMinor
MySQL PDO Cannot assign requested address
Viewed 0 times
cannotaddressmysqlrequestedassignpdo
Problem
Can someone help me with this error?
I have a Server with a lot connections per second; out of about 100 Connections, a single one got this error.
I've tried this recommendation from stackoverflow however it does not solve my problem.
[08-Apr-2013 17:44:08 Europe/Berlin] PHP Warning: PDO::__construct(): [2002]
Cannot assign requested address (trying to connect via tcp://****:3306) in
/var/www/***
[08-Apr-2013 17:44:08 Europe/Berlin] PHP Fatal error: Uncaught exception
'PDOException' with message 'SQLSTATE[HY000] [2002] Cannot assign requested
address' in /var/www/***I have a Server with a lot connections per second; out of about 100 Connections, a single one got this error.
I've tried this recommendation from stackoverflow however it does not solve my problem.
Solution
Using a persistent connection worked for me. The linked recommondation above shows how to create a persistent connection with mysqli. I am using PDO, too. So I had to add the following to my connection-call:
More information and possible limitations can be found here: http://php.net/manual/de/pdo.connections.php
$mysql = new PDO(
"mysql:host=$mySqlServer;dbname=$mySqlDatabase;charset=utf8",
$mySqlUser,
$mySqlPassword,
array(PDO::ATTR_PERSISTENT => true));More information and possible limitations can be found here: http://php.net/manual/de/pdo.connections.php
Code Snippets
$mysql = new PDO(
"mysql:host=$mySqlServer;dbname=$mySqlDatabase;charset=utf8",
$mySqlUser,
$mySqlPassword,
array(PDO::ATTR_PERSISTENT => true));Context
StackExchange Database Administrators Q#39509, answer score: 3
Revisions (0)
No revisions yet.