dbTalk Databases Forums  

Problem with MySQL (somewhat PHP related, MAYBE)

comp.databases.mysql comp.databases.mysql


Discuss Problem with MySQL (somewhat PHP related, MAYBE) in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike
 
Posts: n/a

Default Problem with MySQL (somewhat PHP related, MAYBE) - 01-05-2007 , 11:46 PM






I'm sorry for the multi-post, but I originally checked with the
folks in alt.php.sql newsgroup before coming here.

I'm having a problem with MySQL, and I'm trying to work with PHP,
however, I believe the problem may be on MySQL and not PHP.

So here it goes:

I essentially cannot connect to my MySQL (tried both 5.0.27 and
5.0.30) as root (AT) localhost (DOT) I created the root@localhost user just
fine (I am aware that root@% is NOT the same thing as
root@localhost). However, when I try to connect with a PHP script
as user root@localhost, I get an error message essentially telling
me that the server doesn't exist, or its improperly configured.
However, when I try to connect to the database as
root@LocalMachineHostname it connects no problem.

I have verified that `ping localhost` pings 127.0.0.1, and I have
the proper entry in /etc/hosts showing 127.0.0.1 localhost
localhost.localdomain.

I just can't figure out why MySQL wouldn't let me connect to the
database as root (AT) localhost (DOT)

To make the story just a tad stranger, I'm working on an OS upgrade,
and I am using the same my.cnf file from a working config on a
different machine, (and same php.ini) and I am using the
configure-time options that I used on the original "old" machine.

I'm completely lost, does anyone have any clues as to what could be
going wrong in my connection to mysql?

Thanks

Mike

Reply With Quote
  #2  
Old   
Pascal
 
Posts: n/a

Default Re: Problem with MySQL (somewhat PHP related, MAYBE) - 01-06-2007 , 01:23 AM






Hi Mike,

I am not sure it can help you, but personnally I wouldn't setup in
/etc/hosts localhost.localdomain.
For me, 127.0.0.1 = localhost NO MORE and does not belong to any domain.

Pascal

"Mike" <MikeDawg (AT) gmail (DOT) com> a écrit dans le message de news:
459f3725$0$18068$4c368faf (AT) roadrunner (DOT) com...
Quote:
I'm sorry for the multi-post, but I originally checked with the
folks in alt.php.sql newsgroup before coming here.

I'm having a problem with MySQL, and I'm trying to work with PHP,
however, I believe the problem may be on MySQL and not PHP.

So here it goes:

I essentially cannot connect to my MySQL (tried both 5.0.27 and
5.0.30) as root (AT) localhost (DOT) I created the root@localhost user just
fine (I am aware that root@% is NOT the same thing as
root@localhost). However, when I try to connect with a PHP script
as user root@localhost, I get an error message essentially telling
me that the server doesn't exist, or its improperly configured.
However, when I try to connect to the database as
root@LocalMachineHostname it connects no problem.

I have verified that `ping localhost` pings 127.0.0.1, and I have
the proper entry in /etc/hosts showing 127.0.0.1 localhost
localhost.localdomain.

I just can't figure out why MySQL wouldn't let me connect to the
database as root (AT) localhost (DOT)

To make the story just a tad stranger, I'm working on an OS upgrade,
and I am using the same my.cnf file from a working config on a
different machine, (and same php.ini) and I am using the
configure-time options that I used on the original "old" machine.

I'm completely lost, does anyone have any clues as to what could be
going wrong in my connection to mysql?

Thanks

Mike



Reply With Quote
  #3  
Old   
Dikkie Dik
 
Posts: n/a

Default Re: Problem with MySQL (somewhat PHP related, MAYBE) - 01-06-2007 , 10:14 AM



--8<-- snip --8<--
Quote:
I have verified that `ping localhost` pings 127.0.0.1, and I have
the proper entry in /etc/hosts showing 127.0.0.1 localhost
localhost.localdomain.
So your're probably running Linux. If I recall correctly, connecting to
127.0.0.1 will use a tcp connection, whereas "localhost" would use
something else (a named pipe?).

Is it possible to connect directly to 127.0.0.1 from PHP?

Best regards


Reply With Quote
  #4  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: Problem with MySQL (somewhat PHP related, MAYBE) - 01-06-2007 , 12:36 PM



Mike <MikeDawg (AT) gmail (DOT) com> wrote:

Quote:
I'm having a problem with MySQL, and I'm trying to work with PHP,
however, I believe the problem may be on MySQL and not PHP.

So here it goes:

I essentially cannot connect to my MySQL (tried both 5.0.27 and
5.0.30) as root (AT) localhost (DOT) I created the root@localhost user just
fine (I am aware that root@% is NOT the same thing as
root@localhost). However, when I try to connect with a PHP script
as user root@localhost, I get an error message essentially telling
me that the server doesn't exist, or its improperly configured.
However, when I try to connect to the database as
root@LocalMachineHostname it connects no problem.
Please be more specific. You don't "connect as root@localhost". You
connect to some host, using some MySQL account name and password.

Quote:
I have verified that `ping localhost` pings 127.0.0.1, and I have
the proper entry in /etc/hosts showing 127.0.0.1 localhost
localhost.localdomain.
This has (nearly) nothing to do with MySQL. The string "localhost"
is handled differently by the MySQL client library. If you connect
to "localhost" (not "127.0.0.1", also not "localhost.localdomain")
the client library tries to connect to the MySQL server via the
UNIX socket. This socket looks like a plain file (but shows type
"s" in ls -l). The socket location is a compile time constant with
a default of /tmp/mysql.sock. Some vendors modify that to
/var/lib/mysql/mysql.sock or whatever. The socket location can be
configured in my.cnf as well (overriding the compile time setting).

I guess your PHP uses a different socket location than MySQL and
therefore does not find the MySQL socket.

Please check your my.cnf and php.ini for the value of the "socket"
and "mysql.default_socket" variables. Make sure they point to the
same location.


XL
--
Axel Schwenke, Senior Software Developer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/


Reply With Quote
  #5  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: Problem with MySQL (somewhat PHP related, MAYBE) - 01-06-2007 , 07:27 PM



Quote:
I'm having a problem with MySQL, and I'm trying to work with PHP,
however, I believe the problem may be on MySQL and not PHP.

So here it goes:

I essentially cannot connect to my MySQL (tried both 5.0.27 and
5.0.30) as root (AT) localhost (DOT) I created the root@localhost user just
fine (I am aware that root@% is NOT the same thing as
root@localhost).
When you are using @localhost, both the server and the client MUST
agree on the location (file name, e.g. /tmp/mysql.sock ) of the
socket used for communication. Also, permissions on the parent
directories of the socket may be an issue.

Quote:
However, when I try to connect with a PHP script
as user root@localhost, I get an error message essentially telling
me that the server doesn't exist, or its improperly configured.

However, when I try to connect to the database as
root@LocalMachineHostname it connects no problem.
If that works, why not use it? Yes, there might be a tiny efficiency
difference.

Quote:
I have verified that `ping localhost` pings 127.0.0.1, and I have
the proper entry in /etc/hosts showing 127.0.0.1 localhost
localhost.localdomain.
For MySQL, 'localhost' is *NOT* 127.0.0.1. It's a local named socket.
MySQL seems to work fine if you firewall 127.0.0.1 to block everything
(although the rest of the system may be hurting).

Quote:
I just can't figure out why MySQL wouldn't let me connect to the
database as root (AT) localhost (DOT)
Where does the server think the local socket is (file name)?
Where does the client think the local socket is (file name)?
Are these the same? If not, fix it.

Quote:
To make the story just a tad stranger, I'm working on an OS upgrade,
and I am using the same my.cnf file from a working config on a
different machine, (and same php.ini) and I am using the
configure-time options that I used on the original "old" machine.

I'm completely lost, does anyone have any clues as to what could be
going wrong in my connection to mysql?


Reply With Quote
  #6  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: Problem with MySQL (somewhat PHP related, MAYBE) - 01-06-2007 , 07:30 PM



Quote:
I have verified that `ping localhost` pings 127.0.0.1, and I have
the proper entry in /etc/hosts showing 127.0.0.1 localhost
localhost.localdomain.

So your're probably running Linux. If I recall correctly, connecting to
127.0.0.1 will use a tcp connection, whereas "localhost" would use
something else (a named pipe?).

Is it possible to connect directly to 127.0.0.1 from PHP?
It should be, just log in as "root (AT) 127 (DOT) 0.0.1" and make sure there's a
grant for it ("root@%" would cover it).



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.