Professional Web Applications Themes

Problem with MySQL (somewhat PHP related, MAYBE) - MySQL

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 I created the rootlocalhost user just fine (I am aware that root% is NOT the same thing as rootlocalhost). However, when I try to connect with a PHP script as user rootlocalhost, I get an error message essentially telling me ...

  1. #1

    Default Problem with MySQL (somewhat PHP related, MAYBE)

    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 I created the rootlocalhost user just
    fine (I am aware that root% is NOT the same thing as
    rootlocalhost). However, when I try to connect with a PHP script
    as user rootlocalhost, 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
    rootLocalMachineHostname 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

    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
    Mike Guest

  2. #2

    Default Re: Problem with MySQL (somewhat PHP related, MAYBE)

    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" <com> a écrit dans le message de news:
    459f3725$0$18068$com... 


    Pascal Guest

  3. #3

    Default Re: Problem with MySQL (somewhat PHP related, MAYBE)

    --8<-- snip --8<-- 

    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
    Dikkie Guest

  4. #4

    Default Re: Problem with MySQL (somewhat PHP related, MAYBE)

    Mike <com> wrote:
     

    Please be more specific. You don't "connect as rootlocalhost". You
    connect to some host, using some MySQL account name and password.
     

    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/
    Axel Guest

  5. #5

    Default Re: Problem with MySQL (somewhat PHP related, MAYBE)

    >I'm having a problem with MySQL, and I'm trying to work with PHP, 

    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.
     
     

    If that works, why not use it? Yes, there might be a tiny efficiency
    difference.
     

    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).
     

    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.
     
     

    Gordon Guest

  6. #6

    Default Re: Problem with MySQL (somewhat PHP related, MAYBE)

    >> I have verified that `ping localhost` pings 127.0.0.1, and I have 
    >
    >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?[/ref]

    It should be, just log in as "0.0.1" and make sure there's a
    grant for it ("root%" would cover it).

    Gordon Guest

Similar Threads

  1. Replies: 5
    Last Post: January 14th, 12:19 AM
  2. Two Problems - PHP MySQL Apache related
    By Fkz82 in forum Dreamweaver AppDev
    Replies: 1
    Last Post: March 26th, 12:48 PM
  3. HDR related problem
    By antzz in forum Informix
    Replies: 0
    Last Post: September 8th, 02:58 PM
  4. MySQL error - related to php.ini?
    By matty in forum PHP Development
    Replies: 1
    Last Post: August 7th, 03:05 AM
  5. A MySQL Question (PHP Related)
    By stephan beal in forum PHP Development
    Replies: 1
    Last Post: July 31st, 05:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139