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

php.internals

Sam Hobbs

21 years ago
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.

Rasmus Lerdorf

21 years ago
On Wed, 15 Sep 2004, 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 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

Adam Maccabee Trachtenberg

21 years ago
On Wed, 15 Sep 2004, Rasmus Lerdorf wrote:
> On Wed, 15 Sep 2004, 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)
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!

Sam Hobbs

21 years ago
"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.

Adam Maccabee Trachtenberg

21 years ago
On Thu, 16 Sep 2004, Sam Hobbs wrote:
> "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?
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!

Sam Hobbs

21 years ago
"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?

Adam Maccabee Trachtenberg

21 years ago
On Thu, 16 Sep 2004, Sam Hobbs wrote:
> "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.
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!

Sam Hobbs

21 years ago
"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.

Georg Richter

21 years ago
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

Sam Hobbs

21 years ago
"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.

Derick Rethans

21 years ago
On Fri, 17 Sep 2004, Sam Hobbs wrote:
> "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.
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

Sam Hobbs

21 years ago
"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.

Rasmus Lerdorf

21 years ago
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 On Thu, 16 Sep 2004, Sam Hobbs wrote:

Sam Hobbs

21 years ago
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...

Andrey Hristov

21 years ago
Sam Hobbs wrote:
> "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. >
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

Sam Hobbs

21 years ago
"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.

Andrey Hristov

21 years ago
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

Sam Hobbs

21 years ago
"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.

Andrey Hristov

21 years ago
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

Sam Hobbs

21 years ago
"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.

Cris H

21 years ago
> > "Andrey Hristov" <php@hristov.com> wrote: > > 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.
> Sam Hobbs <SoCalSam@GMail.com> > 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.
I think this is down to a difference between the way the TCP/IP stacks work on the relevant systems. Linux seems to take a "short cut" higher up the stack, so that anything directed to the local loop-back address never really touches the stack itself. If you use ethereal (http://www.ethereal.com/) to monitor the connections on a Linux system, you'll see nothing at all captured for "local" connections. I understand (it's been a while) that Windows behaves slightly differently and has no real loop-back, so it uses the stack eben for local connections. I have a vague recollection of similar issues using a home-grown server a few years ago. This page (http://www.ethereal.com/media.html) has a bit more information in the differences between the loop-back mechanisms on each system. You may also want to check that everything is set up correctly in your 'hosts' file (C:\Windows\hosts ?) so that the system itself knows as much as it can. Cris H ___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

Sam Hobbs

21 years ago
"Cris H" <cysgwr_eryri@yahoo.co.uk> wrote in message news:20040917015257.67611.qmail@web25106.mail.ukl.yahoo.com...
> > I understand (it's been a while) that Windows behaves slightly > differently and has no real loop-back, so it uses the stack eben > for local connections. I have a vague recollection of similar > issues using a home-grown server a few years ago. This page > (http://www.ethereal.com/media.html) has a bit more information > in the differences between the loop-back mechanisms on each > system.
You know more than I do, although our minds do get filled with details and I sure need refreshers of details often. I have been successful in writing a few simple samples of sending and/or receiving UDP. In particular, see my: UDP Send and Receive Using CAsyncSocket http://simplesamples.info/MFC/UDPSendReceive.php I tried it to see what happens relevant to this discussion, and got some interesting results. When I remove ZoneAlarm's configuration of the program, so that it does not know anything about the UDPSendReceive program, then when I execute the program, ZoneAlarm asks if it can access the internet. If I answer by saying to deny access, then the send does not work. However every subsequent send (without closing the socket) works. If when I tell ZoneAlarm to deny access, I also specify to save that answer, then when I execute the program ZoneAlarm does not ask anything, as it should (not), but the first send does not work. Every subsequent send does work. So I am a little confused, but this is not a php topic. I am curious about the details and I will check into it when I have time, but I will go to a networking group or forum to pursue this further. I have used ethereal but it has been a while. I have not read that article but that is where I am likely to start when I pursue the issues I describe above.
> You may also want to check that everything is set up > correctly in your 'hosts' file (C:\Windows\hosts ?) so that the > system itself knows as much as it can.
I have the following in my hosts file: 127.0.0.1 localhost I assume that is correct.