Bug #73757 [Fbk->Opn]: Slow connection when using localhost as DSN

From: Date: Tue, 20 Dec 2016 20:09:51 +0000
Subject: Bug #73757 [Fbk->Opn]: Slow connection when using localhost as DSN
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206164@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73757&edit=1 ID: 73757 User updated by: binarskugga at gmail dot com Reported by: binarskugga at gmail dot com Summary: Slow connection when using localhost as DSN -Status: Feedback +Status: Open Type: Bug Package: PDO MySQL Operating System: Windows PHP Version: 7.1.0 Block user comment: N Private report: N New Comment: Thanks for the answer ! Indeed works with regular IPv4 address. Also didn't know it was trying to solve it into an IPv6 first. Previous Comments: ------------------------------------------------------------------------ [2016-12-20 19:39:23] danack@php.net The slowness is very likely to be how networks work on Windows: http://stackoverflow.com/questions/11663860/mysql-connect-localhost-127-0-0-1-slow-on-windows-platform/11667268#11667268 If that issue is affecting you then, either changing MySQL to listen to IPv6 loopback address of ::1 would fix this, as would changing your network to only use an IPv4 address. I pretty strongly recommend just using the actual IP address though, and just avoiding the magic localhost name. ------------------------------------------------------------------------ [2016-12-16 08:00:12] binarskugga at gmail dot com Tested with MySQL. ------------------------------------------------------------------------ [2016-12-16 07:59:05] binarskugga at gmail dot com Description: ------------ --- From manual page: http://www.php.net/pdo.construct --- When connecting to PDO using the DSN, it is painfully slow on local if you're using "localhost". This can be fixed by using 127.0.0.1 at the moment. Test script: --------------- <?php try { $pdo = new PDO(mysql:dbname=foo;host=localhost;port=3306", $config["SQL"]["USER"], $config["SQL"]["PASSWORD"]); } catch(PDOException $exception) { die("Couldn't access SQL engine. (" . $exception->getMessage() . ")"); } ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73757&edit=1

« previous php.bugs (#206164) next »