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
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:
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_openis good enough to start the mysql process, but yet not complete enough so that calls toLoadLibraryfrom 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.