I have the following code
$env=array('PATH'=>'C:\Program Files\MySQL\MySQL Server 5.1\bin',
'PATHEXT' => '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC');
$cmd='mysql "--port=3306" "--host=127.0.0.1" "--user=root" "--password=xxxx" <"C:\Projects/script.sql" 2>&1';
print $cmd;
$proc = proc_open($cmd, $descriptorspec, $pipes, NULL, $env) or die("Cannot run $cmd");
while ($line=fgets($pipes[1])) print $line;
print "\n\nCompleted\n";
And the output I get is
ERROR 2004 (HY000): Can't create TCP/IP socket (10106)
Why is the port option being ignored? The command works perfectly well on the command line.
The error seen
ERROR 2004 (HY000): Can't create TCP/IP socket (10106)
is raised by mysql, so the mysql process actually started.
This error corresponds to CR_IPSOCK_ERROR
, and it prints the underlying root cause of the problem: 10106
.
A quick search gives:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668%28v=vs.85%29.aspx
and in particular:
WSAEPROVIDERFAILEDINIT
10106
Service provider failed to initialize.
The requested service provider could not be loaded or initialized. This error is returned if either a service provider's DLL could not be loaded (LoadLibrary failed) or the provider's WSPStartup or NSPStartup function failed.
I don't think this has anything to do with the port number being "ignored", and even less firewall issues.
It appears as if the environment created by proc_open
is good enough to start the mysql process, but yet not complete enough so that calls to LoadLibrary
from within that process, to load the networking code namely, are failing.
The same command works from the command line, most likely because the environment in the command line contains much more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With