Can't create TCP/IP socket (10106) - MySQL Connectivity Issu

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rblan
Forum Newbie
Posts: 4
Joined: Thu Sep 19, 2002 3:07 pm
Location: Woodstock, Georgia

Can't create TCP/IP socket (10106) - MySQL Connectivity Issu

Post by rblan »

Here's the simple .PHP script I developed to try and get PHP to connect to MySQL on a Windows Pro Server 2000 box.

Code: Select all

<?php

    /* Connecting, selecting database */

    print "attempting to commect to database";

    $link = mysql_connect("localhost:3306", "root", "m@st0lf")
        or die("Could not connect");

    print "Connected successfully";

    mysql_select_db("mysql") or die("Could not select database");

    /* Performing SQL query */

    $query = "SELECT * FROM mysql";

    $result = mysql_query($query) or die("Query failed");

    /* Printing results in HTML */

    print "<table>\n";

    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        print "\t<tr>\n";
        foreach ($line as $col_value) {
            print "\t\t<td>$col_value</td>\n";
        }
        print "\t</tr>\n";
    }
    print "</table>\n";

    /* Free resultset */

    mysql_free_result($result);

    /* Closing connection */

    mysql_close($link);

?>

-------------------------------------------------------------------------------


Here's the response I get ..


attempting to commect to database
Warning: Can't create TCP/IP socket (10106) in c:\orion\default-web-app\forums\testsql.php on line 7

Warning: MySQL Connection Failed: Can't create TCP/IP socket (10106) in c:\orion\default-web-app\forums\testsql.php on line 7
Could not connect

------------------------------------------------------------------------------

Any insight or assistance would be most appreciative. I'm sort of at my end on this one.

Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

10106 WSAEPROVIDERFAILEDINIT The requested service provider could not be loaded or initialized.
which version of php and mysql?
Did the mysql-server start without errors?
rblan
Forum Newbie
Posts: 4
Joined: Thu Sep 19, 2002 3:07 pm
Location: Woodstock, Georgia

Post by rblan »

PHP 4.2.3
Mysql 3.23.47-max
rblan
Forum Newbie
Posts: 4
Joined: Thu Sep 19, 2002 3:07 pm
Location: Woodstock, Georgia

Post by rblan »

And, MySQL does start clean without errors.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

odd. The error states that the tcp/ip layer for networking could not be initialized. I'm only fishing since I saw this error only once for a banyan vines network (and it WAS broken ;) )

what happens when you use php-cli.exe from commandline?
you can connect using the client provided by mysql-distribution?
rblan
Forum Newbie
Posts: 4
Joined: Thu Sep 19, 2002 3:07 pm
Location: Woodstock, Georgia

Post by rblan »

Ok, It seems that my problem is not PHP, it's something within the MySQL startup options. When I do the php-cli.exe as you suggested, I get the following ...


C:\orion\default-web-app\forums>dir t*.php
Volume in drive C has no label.
Volume Serial Number is 9822-9391

Directory of C:\orion\default-web-app\forums

09/20/2002 08:08a 886 testsql.php
09/13/2002 01:01a 4,057 threadrate.php
2 File(s) 4,943 bytes
0 Dir(s) 737,218,560 bytes free

C:\orion\default-web-app\forums>php-cli testsql.php
attempting to commect to database
Warning: Can't open named pipe to host: . pipe: MySQL (2) in testsql.php on l
e 7

Warning: MySQL Connection Failed: Can't open named pipe to host: . pipe: MySQ
(2)
in testsql.php on line 7
Could not connect
C:\orion\default-web-app\forums>

---------------------------------

It would seem that the mysql windows client is attempting to use named pipes rather than tcp. According to what I've been able to find in doc and on the net, I should be able to put the keyword "host = localhost" in the my.cnf options file. However, mysqld-max didn't like that option and wouldn't startup - saying that it was an invalid option. I went ahead and upgraded mysql to a newer version which supposedly only uses named pipes when the --enable-named-pipes option is used. I get the same results. Any ideas would be greatly appreciated.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

stranger and stranger ;)
try to start mysqld-nt with --enable-named-pipe
Post Reply