# mysql_connect using version 5.0.1 accesses the internet when host and client are the same system

- Thread: https://externals.io/message/12848
- Original archive: https://news-web.php.net/php.internals/12848
- Started by Sam Hobbs on 2004-09-16T04:01:05+00:00
- Messages: 20
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12848 — Sam Hobbs — 2004-09-16T04:01:05+00:00

URL: https://externals.io/message/12848#12848

I am using PHP Version 5.0.1, MySQL 5.0.1-alpha-nt, and Apache/2.0.48 with 
Windows XP with SP2. When I use mysql_connect in a php page in Apache to 
connect to the "localhost" I get:

   Warning: mysql_connect() [function.mysql-connect.chm]: Can't connect to 
MySQL server on 'localhost' (10061)

I get that when the firewall does not allow Apache and MySQL to access the 
internet. When I do allow Apache to access the internet, mysql_connect with 
the same parameters works. Is that waht is supposed to happen?

I assume this is a PHP problem but I can't be sure it is, so I apologize if 
it is not.

I realize that I have not provided much information. If access to the 
internet is normal when the server and client are in the same system, then I 
won't spend much more time on this. If however it sounds like a bug, then I 
will gather as much information that I can and submit a bug report.

---

## #12849 — Rasmus Lerdorf — 2004-09-16T04:43:03+00:00

URL: https://externals.io/message/12848#12849 · In reply to: #12848

> I am using PHP Version 5.0.1, MySQL 5.0.1-alpha-nt, and Apache/2.0.48 with
> Windows XP with SP2. When I use mysql_connect in a php page in Apache to
> connect to the "localhost" I get:
>
>    Warning: mysql_connect() [function.mysql-connect.chm]: Can't connect to
> MySQL server on 'localhost' (10061)
>
> I get that when the firewall does not allow Apache and MySQL to access the
> internet. When I do allow Apache to access the internet, mysql_connect with
> the same parameters works. Is that waht is supposed to happen?
>
> I assume this is a PHP problem but I can't be sure it is, so I apologize if
> it is not.

I am not sure why you assume this to be a PHP problem.  Sounds like your
firewall is blocking both local and external connections.  Can you telnet
to port 10061 on localhost with the firewall enabled?

-Rasmus

---

## #12850 — Adam Maccabee Trachtenberg — 2004-09-16T06:06:23+00:00

URL: https://externals.io/message/12848#12850 · In reply to: #12849

> 
> > […]

Also, are you really using the mysql extension with MySQL 5.0.1? If
so, you need to make sure you pass special flags to MySQL to make it
play nice with the older client libraries.

-adam

-- 
adam@trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!

---

## #12853 — Andrey Hristov — 2004-09-16T07:44:10+00:00

URL: https://externals.io/message/12848#12853 · In reply to: #12848

Sam Hobbs wrote:
> I am using PHP Version 5.0.1, MySQL 5.0.1-alpha-nt, and Apache/2.0.48 with 
> Windows XP with SP2. When I use mysql_connect in a php page in Apache to 
> connect to the "localhost" I get:
> 
>    Warning: mysql_connect() [function.mysql-connect.chm]: Can't connect to 
> MySQL server on 'localhost' (10061)
> 
> I get that when the firewall does not allow Apache and MySQL to access the 
> internet. When I do allow Apache to access the internet, mysql_connect with 
> the same parameters works. Is that waht is supposed to happen?
> 
> I assume this is a PHP problem but I can't be sure it is, so I apologize if 
> it is not.
> 
> I realize that I have not provided much information. If access to the 
> internet is normal when the server and client are in the same system, then I 
> won't spend much more time on this. If however it sounds like a bug, then I 
> will gather as much information that I can and submit a bug report.
> 
Hi,
AFAIK MySQL on windows by default tries to use TCP/IP, this differs from the
default behavior on *nix, where it tries to Unix socket and after that TCP/IP.
On windows nt one can use named pipes, however they are not enabled by
default. Use --enable-named-pipe, or just --skip-networking. The latter instructs
MySQL not to use TCP/IP.
More info here : http://dev.mysql.com/doc/mysql/en/Can_not_connect_to_server.html

HTH,
Andrey

---

## #12872 — Sam Hobbs — 2004-09-16T17:07:09+00:00

URL: https://externals.io/message/12848#12872 · In reply to: #12849

"Rasmus Lerdorf" <rasmus@php.net> wrote in message 
news:Pine.LNX.4.58.0409152141160.1427@t42p.lerdorf.com...
>
> I am not sure why you assume this to be a PHP problem.

I thought I was being reasonable. I thought I was clear about saying I was 
not sure it is a PHP problem. I was trying to help by helping diagnose a 
problem. If it is not a problem then you could say so in a more reasonable 
manner. If you always react to people this way when they are trying to help 
then you will have an inferior product since you discourage people from 
helping.

I am not assuming; that is why I am asking this question. You really can say 
the same thing except without the emotions. You can simply state the fact 
that as far as you know it is not a PHP problem. It really, really helps to 
keep in mind that it is better to simply state facts. That keeps things less 
emotional and generally keeps things at a more reasonable level.

> Sounds like your
> firewall is blocking both local and external connections.  Can you telnet
> to port 10061 on localhost with the firewall enabled?

I think the PHP messages need to be documented. It is unclear whether 10061 
is a port or an error code. Are you sure it is a port? I am not aware of 
MySQL using port 10061. I did not change anything to specify port 10061 and 
this is a fresh install of MySQL.

Again, if you think that what I described sounds like it is normal behavior, 
then simply saying so helps a lot. If it is normal behavior, then it would 
probably help a lot of people to say so somewhere.

One reason I say that the PHP messages need to be documented better is 
indicated by all the many others with the same problem. If you search for:

    +mysql_connect +10061

You will find many web sites that have that error. It is a common problem 
that many people are encountering and it appears that many people don't know 
how to solve it; their web sites are down. Many of the other results are 
from people asking about the problem and it is not clear how many of them 
have not solved the problem. It appears that many have not.

---

## #12873 — Sam Hobbs — 2004-09-16T17:10:47+00:00

URL: https://externals.io/message/12848#12873 · In reply to: #12850

"Adam Maccabee Trachtenberg" <adam@trachtenberg.com> wrote in message 
news:Pine.LNX.4.58.0409160204520.13565@miranda.org...
>
> Also, are you really using the mysql extension with MySQL 5.0.1? If
> so, you need to make sure you pass special flags to MySQL to make it
> play nice with the older client libraries.

I am sorry, I don't understand. Is that documented? If it is documented, 
then I will find it. If it is not documented (I know this version of php is 
still being tested) where can I look for the information?

Also, note that the mysql_connect works if I tell my firewall to allow 
Apache to access the internet.

---

## #12875 — Andrey Hristov — 2004-09-16T17:11:46+00:00

URL: https://externals.io/message/12848#12875 · In reply to: #12872

Sam Hobbs wrote:
> "Rasmus Lerdorf" <rasmus@php.net> wrote in message 
> news:Pine.LNX.4.58.0409152141160.1427@t42p.lerdorf.com...
> 
> > […]
> 
> 
> I thought I was being reasonable. I thought I was clear about saying I was 
> not sure it is a PHP problem. I was trying to help by helping diagnose a 
> problem. If it is not a problem then you could say so in a more reasonable 
> manner. If you always react to people this way when they are trying to help 
> then you will have an inferior product since you discourage people from 
> helping.
> 
> I am not assuming; that is why I am asking this question. You really can say 
> the same thing except without the emotions. You can simply state the fact 
> that as far as you know it is not a PHP problem. It really, really helps to 
> keep in mind that it is better to simply state facts. That keeps things less 
> emotional and generally keeps things at a more reasonable level.
> 
> 
> > […]
> 
> 
> I think the PHP messages need to be documented. It is unclear whether 10061 
> is a port or an error code. Are you sure it is a port? I am not aware of 
> MySQL using port 10061. I did not change anything to specify port 10061 and 
> this is a fresh install of MySQL.
> 
> Again, if you think that what I described sounds like it is normal behavior, 
> then simply saying so helps a lot. If it is normal behavior, then it would 
> probably help a lot of people to say so somewhere.
> 
> One reason I say that the PHP messages need to be documented better is 
> indicated by all the many others with the same problem. If you search for:
> 
>     +mysql_connect +10061
> 
> You will find many web sites that have that error. It is a common problem 
> that many people are encountering and it appears that many people don't know 
> how to solve it; their web sites are down. Many of the other results are 
> from people asking about the problem and it is not clear how many of them 
> have not solved the problem. It appears that many have not.
> 
AFAIK this is _not_ a PHP error message. You see it thrown by ext/mysql however
it comes from the underlying libmysql. Therefore all scripting and non-scripting
languages relying on this library will show you the same error. I hope you have
read the appendix of the mysql manual where it is stated that users may have
problem connecting to mysql over tcp/ip under windows if they have enabled
firewall software like ZoneAlarm or Windows Personal Firewall. In this case either
don't do tcp/ip and enable windows pipes, which are faster (i saw today a
synthetic benchmark which stated that they are 3x faster), or allow connections
to 3306.

Andrey

---

## #12874 — Rasmus Lerdorf — 2004-09-16T17:12:44+00:00

URL: https://externals.io/message/12848#12874 · In reply to: #12872

Uh, I have no idea where ths reaction came from.  I was asking you to dig
a little deeper by telnetting to whatever port you have MySQL listening
to.  If you can't get to the port yourself, then obviously PHP can't
either and it wouldn't be a PHP problem.

-Rasmus



> "Rasmus Lerdorf" <rasmus@php.net> wrote in message
> news:Pine.LNX.4.58.0409152141160.1427@t42p.lerdorf.com...
> > […]
>
> I thought I was being reasonable. I thought I was clear about saying I was
> not sure it is a PHP problem. I was trying to help by helping diagnose a
> problem. If it is not a problem then you could say so in a more reasonable
> manner. If you always react to people this way when they are trying to help
> then you will have an inferior product since you discourage people from
> helping.
>
> I am not assuming; that is why I am asking this question. You really can say
> the same thing except without the emotions. You can simply state the fact
> that as far as you know it is not a PHP problem. It really, really helps to
> keep in mind that it is better to simply state facts. That keeps things less
> emotional and generally keeps things at a more reasonable level.
>
> > […]
>
> I think the PHP messages need to be documented. It is unclear whether 10061
> is a port or an error code. Are you sure it is a port? I am not aware of
> MySQL using port 10061. I did not change anything to specify port 10061 and
> this is a fresh install of MySQL.
>
> Again, if you think that what I described sounds like it is normal behavior,
> then simply saying so helps a lot. If it is normal behavior, then it would
> probably help a lot of people to say so somewhere.
>
> One reason I say that the PHP messages need to be documented better is
> indicated by all the many others with the same problem. If you search for:
>
>     +mysql_connect +10061
>
> You will find many web sites that have that error. It is a common problem
> that many people are encountering and it appears that many people don't know
> how to solve it; their web sites are down. Many of the other results are
> from people asking about the problem and it is not clear how many of them
> have not solved the problem. It appears that many have not.

---

## #12876 — Sam Hobbs — 2004-09-16T17:23:55+00:00

URL: https://externals.io/message/12848#12876 · In reply to: #12853

"Andrey Hristov" <php@hristov.com> wrote in message 
news:4149444A.9000503@hristov.com...
> > […]
> Hi,
> AFAIK MySQL on windows by default tries to use TCP/IP, this differs from 
> the
> default behavior on *nix, where it tries to Unix socket and after that 
> TCP/IP.
> On windows nt one can use named pipes, however they are not enabled by
> default. Use --enable-named-pipe, or just --skip-networking. The latter 
> instructs
> MySQL not to use TCP/IP.
> More info here : 
> http://dev.mysql.com/doc/mysql/en/Can_not_connect_to_server.html


Thank you. If that is what is happening then I agree that it is not PHP 
issue, so I am happy to go elsewhere for help. The only relevant suggestion 
is that it might help to impove the warning message and to put something in 
the php documentation to help people know where to look. Many people are 
having problems with this.

I have seen the "MySQL Manual | A.2.2 Can't connect to [local] MySQL server" 
page. It is confusing, since the title says "[local]" yet the last item on 
the page that says to check the firewall says "to allow external access", 
which I interpreted to mean not-local access.

I wish I knew what the disadvantage of pipes are. That is not a php issue, 
though; it is something that the MySQL documentation should clarify. 
Probably pipes work great if there is no need to access MySQL outside of the 
system it is installed in. If so, then it would help for the MySQL 
documentation to say so explicitely. It might say that, but I have not seen 
it said. I know that MySQL does poll the internet very, very often and if 
turning off it's use of the network eliminates access to the internet then 
that is one less thing to be concerned about.

---

## #12877 — Andrey Hristov — 2004-09-16T17:32:34+00:00

URL: https://externals.io/message/12848#12877 · In reply to: #12876

Sam Hobbs wrote:
> Thank you. If that is what is happening then I agree that it is not PHP 
> issue, so I am happy to go elsewhere for help. The only relevant suggestion 
> is that it might help to impove the warning message and to put something in 
> the php documentation to help people know where to look. Many people are 
> having problems with this.
> 
> I have seen the "MySQL Manual | A.2.2 Can't connect to [local] MySQL server" 
> page. It is confusing, since the title says "[local]" yet the last item on 
> the page that says to check the firewall says "to allow external access", 
> which I interpreted to mean not-local access.
> 
> I wish I knew what the disadvantage of pipes are. That is not a php issue, 
> though; it is something that the MySQL documentation should clarify. 
> Probably pipes work great if there is no need to access MySQL outside of the 
> system it is installed in. If so, then it would help for the MySQL 
> documentation to say so explicitely. It might say that, but I have not seen 
> it said. I know that MySQL does poll the internet very, very often and if 
> turning off it's use of the network eliminates access to the internet then 
> that is one less thing to be concerned about.
> 
Maybe Windows is different than Linux in the way it handles connections on
127.0.0.1 ? What leads me to think about this is that only Windows firewalls
are mentioned.

Andrey

---

## #12878 — Sam Hobbs — 2004-09-16T17:47:22+00:00

URL: https://externals.io/message/12848#12878 · In reply to: #12875

"Andrey Hristov" <php@hristov.com> wrote in message 
news:4149C952.2070507@hristov.com...
>
> AFAIK this is _not_ a PHP error message.

Look at the message (in my original post) again. It sure looks like a php 
message to me, but perhaps I misunderstand. Is "mysql_connect()" a php 
function or a libmysql function? Also, the reverence to the manual 
"[function.mysql-connect.chm]" is in the message (I think because I turned 
on the option for it); is that a reference to the php documentation or MySQL 
documentation? If it is a libmysql message, then it is not clear to me that 
it is. How am I supposed to know that?

> I hope you have
> read the appendix of the mysql manual where it is stated that users may 
> have
> problem connecting to mysql over tcp/ip under windows if they have enabled
> firewall software like ZoneAlarm or Windows Personal Firewall.

If you mean the "MySQL Manual | A.2.2 Can't connect to [local] MySQL server" 
page, then it is misleading; see my other reply about it.

And again, many people are having this problem. A small hint in the (or a) 
php message and in the php documentation will likely help many people.

---

## #12879 — Adam Maccabee Trachtenberg — 2004-09-16T17:48:28+00:00

URL: https://externals.io/message/12848#12879 · In reply to: #12873

> "Adam Maccabee Trachtenberg" <adam@trachtenberg.com> wrote in message
> news:Pine.LNX.4.58.0409160204520.13565@miranda.org...
> > […]
>
> I am sorry, I don't understand. Is that documented? If it is documented,
> then I will find it. If it is not documented (I know this version of php is
> still being tested) where can I look for the information?

http://dev.mysql.com/doc/mysql/en/Old_client.html

-adam

-- 
adam@trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!

---

## #12880 — Sam Hobbs — 2004-09-16T17:54:44+00:00

URL: https://externals.io/message/12848#12880 · In reply to: #12874

First let me say that I would not have reacted as strongly if it were not 
true that I get so many negative reactions when I just try to help. You have 
not seen those others so if you want to assume they are justified then we 
can simply disagree. However I sure feel as if people are much too quick to 
be negative.

I reacted to the comment "I am not sure why you assume". If another way of 
saying what you meant is that you think it is not a PHP problem, then just 
saying that you think it is not a PHP problem says what you are thinking and 
is not negative.


"Rasmus Lerdorf" <rasmus@php.net> wrote in message 
news:Pine.LNX.4.58.0409161011450.1282@t42p.lerdorf.com...
> Uh, I have no idea where ths reaction came from.  I was asking you to dig
> a little deeper by telnetting to whatever port you have MySQL listening
> to.  If you can't get to the port yourself, then obviously PHP can't
> either and it wouldn't be a PHP problem.
>
> -Rasmus
>
> 
>
> > […]

---

## #12881 — Sam Hobbs — 2004-09-16T18:01:41+00:00

URL: https://externals.io/message/12848#12881 · In reply to: #12877

"Andrey Hristov" <php@hristov.com> wrote in message 
news:4149CE32.2070207@hristov.com...
>  Maybe Windows is different than Linux in the way it handles connections 
> on
> 127.0.0.1 ? What leads me to think about this is that only Windows 
> firewalls
> are mentioned.

This is possible and if so then I agree that it is not a php problem and 
there is not much more for php to do than to give a hint somewhere.

It seems that Windows uses TCP/IP more than Linux and that might be the only 
difference.

---

## #12882 — Sam Hobbs — 2004-09-16T18:08:32+00:00

URL: https://externals.io/message/12848#12882 · In reply to: #12879

"Adam Maccabee Trachtenberg" <adam@trachtenberg.com> wrote in message 
news:Pine.LNX.4.58.0409161343440.15542@miranda.org...
>
> http://dev.mysql.com/doc/mysql/en/Old_client.html

Does the mysql extension use a "pre-4.1" client? Perhaps the php 
documentation answers that and if so then I don't expect you to answer that.

Note that in this situation, it is a fresh install of MySQL and I am not 
using passwords. In that situation, the "Client does not support 
authentication protocol" does not apply, correct?

---

## #12884 — Adam Maccabee Trachtenberg — 2004-09-16T19:20:17+00:00

URL: https://externals.io/message/12848#12884 · In reply to: #12882

> "Adam Maccabee Trachtenberg" <adam@trachtenberg.com> wrote in message
> news:Pine.LNX.4.58.0409161343440.15542@miranda.org...
> > […]
>
> Does the mysql extension use a "pre-4.1" client? Perhaps the php
> documentation answers that and if so then I don't expect you to answer that.

It's not whether I'm willing or not willing to answer the question
just because it's in the documentation, as documentation can be
confusing or have information placed in hard-to-find locations.

It's more a question of whether it looks like you did some
investigation before asking a question on the internals list.

In this case, there is a line on the main page of the mysql docs on
php.net that says:

"This MySQL extension doesn't support full functionality of MySQL
versions greater than 4.1.0. For that, use MySQLi."

http://us2.php.net/mysql

So, my initial question to myself is "Why is Sam trying to use the
mysql extension to talk to MySQL 5.0.1, and has he tried mysqli?"

> Note that in this situation, it is a fresh install of MySQL and I am not
> using passwords. In that situation, the "Client does not support
> authentication protocol" does not apply, correct?

I cannot say. However, this is really a more of a MySQL question than
a PHP one. The mysql extension uses the old C libraries, so it will
work just like every other MySQL client.

-adam

-- 
adam@trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!

---

## #12889 — Georg Richter — 2004-09-17T05:12:03+00:00

URL: https://externals.io/message/12848#12889 · In reply to: #12882

Am Do, den 16.09.2004 schrieb Sam Hobbs um 20:08:

> Note that in this situation, it is a fresh install of MySQL and I am not 
> using passwords. In that situation, the "Client does not support 
> authentication protocol" does not apply, correct?

If you're using MySQL 4.1 or above you should use the same client
library - even if the authentication is not a problem, you will run into
several problems when retrieving resultsets metadata.

/Georg

-- 
Georg Richter, Senior Software Developer
MySQL AB, www.mysql.com

Are you MySQL certified?  www.mysql.com/certification

---

## #12893 — Sam Hobbs — 2004-09-17T14:22:50+00:00

URL: https://externals.io/message/12848#12893 · In reply to: #12884

"Adam Maccabee Trachtenberg" <adam@trachtenberg.com> wrote in message 
news:Pine.LNX.4.58.0409161509100.15542@miranda.org...
>
> In this case, there is a line on the main page of the mysql docs on
> php.net that says:
>
> "This MySQL extension doesn't support full functionality of MySQL
> versions greater than 4.1.0. For that, use MySQLi."
>
> http://us2.php.net/mysql

That is confusing for me. I interpret that to mean that the MySQL extension 
doesn't support any features of MySQL added to versions greater than 4.1.0 
and if I don't need the additional features then I can use the MySQL 
extension.

> So, my initial question to myself is "Why is Sam trying to use the
> mysql extension to talk to MySQL 5.0.1, and has he tried mysqli?"

I see nothing telling me not to use the mysql extension. I also do not see a 
line in my php.ini file that says "extension=php_mysqli.dll" (either 
commented or not commented); I did thave a line that said 
";extension=php_mysql.dll" that I uncommented of course.

> I cannot say. However, this is really a more of a MySQL question than
> a PHP one. The mysql extension uses the old C libraries, so it will
> work just like every other MySQL client.

That's fine. I did not know and now that you have said that, I now know. I 
was trying to help and as best as I knew it seemed to be a php problem. I 
will assume you people do know enough to make the determination and 
therefore I will assume it is accurate. It sure is less work for me to not 
pursue it further.

---

## #12894 — Sam Hobbs — 2004-09-17T14:24:53+00:00

URL: https://externals.io/message/12848#12894 · In reply to: #12889

"Georg Richter" <georg@mysql.com> wrote in message 
news:1095397923.30170.2104.camel@beethoven.local...
>
> If you're using MySQL 4.1 or above you should use the same client
> library - even if the authentication is not a problem, you will run into
> several problems when retrieving resultsets metadata.

I don't understand this but it seems irrelevant to me. If it is relevant 
then I don't undersand this well enough to know what to do or to look at.

---

## #12895 — Derick Rethans — 2004-09-17T14:30:03+00:00

URL: https://externals.io/message/12848#12895 · In reply to: #12894

> "Georg Richter" <georg@mysql.com> wrote in message
> news:1095397923.30170.2104.camel@beethoven.local...
> > […]
>
> I don't understand this but it seems irrelevant to me. If it is relevant
> then I don't undersand this well enough to know what to do or to look at.

Please take this discussion off this list, it is not relevant and has
nothing to do with PHP internals.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org
