1

I am trying to test a website on a local machine that has Windows 7 installed. I want to use named pipes to connect to the MySQL server, but mysql_connect() seems to throw an error:

[2002] No connection could be made because the target machine actively (trying to connect via tcp://localhost:3306)

For some reason it's still using TCP. I'm testing with a simple PHP (5.3) script:

<?php

mysql_connect("localhost", "root", "password") or die();

echo "It works!";

?>

The MySQL client works fine. It's just a problem with PHP (note: using TCP instead works).

This is what I have in my.ini:

[client]

pipe
socket=mysql

[mysqld]

skip-networking
enable-named-pipe
socket=mysql

I tried setting these variables in php.ini:

pdo_mysql.default_socket = mysql
mysql.default_socket = mysql
mysqli.default_socket = mysql
someguy
  • 133
  • 5
  • Well, I'm used to work with CentOS/RHEL desktop/server, and never get this error before. I know that php and mysql tend to get error on windows 7. Did you try your code on another computer? Xp? linux? Maybe the problem is from your 7. – Anarko_Bizounours Jun 27 '11 at 11:02
  • @Anarko_Bizounours I've never tried with named pipes. [Here](http://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html) it says that specifying the host name as `.` forces the use of named pipes in Windows, but I get "no such host is known". It still seems to be using TCP (trying to connect via tcp://.:3306). – someguy Jun 27 '11 at 11:15
  • By all that's holy, don't use bare `mysql_*`. Use `mysqli` or `PDO`. – Shadur Dec 11 '14 at 08:11

1 Answers1

1

This appears to be a bug affecting the VC9 binaries. See: http://bugs.php.net/bug.php?id=48082 (if the link doesn't work, try this cached version). According to andrey@php.net:

A patch is being worked on.

Support will be in the next minor PHP version, be it 5.4 or something else.

5.3.x won't get this, as this is classified as new feature.


As the person that asked this question, I'd like to mention that I was using the Apache web server. The PHP downloads page for Windows does say that VC9 binaries should not be used with Apache (I was not aware at the time), but this seems to be a separate issue, since IIS users also had the same problem, if you look at the bug report.

someguy
  • 133
  • 5
  • To clarify something (since you have read just first part of 2-sentenced message): The PHP downloads page for Windows says: _Do NOT use VC9 version with **apache.org** binaries. **VC9 versions of Apache** can be fetched at Apache Lounge. **We use their binaries to build the Apache SAPIs**._ – LazyOne Jun 27 '11 at 21:11
  • @LazyOne Yes, when I said VC9 binaries should not be used with Apache, I meant the apache.org binaries, not Apache, sorry. I was just pointing out that this is a separate issue. – someguy Jun 28 '11 at 10:09