The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Accessing MySQL Using Server IP Address

Discussion in 'General Discussion' started by jondolar, Jul 6, 2005.

  1. jondolar

    jondolar Well-Known Member

    Joined:
    Feb 15, 2004
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    I have a customer that for some reason does not want to access MySQL using "localhost" from his php script. He wants to put in the server IP address.

    When he puts in the IP address of the script the script will not connect to the database. When he puts in "localhost" it works fine.

    Why can't php connect to MySQL using the IP address when the script is on the same server as MySQL.

    NOTE: He can access the MySQL server from another web server using the IP address just fine. It's just that he can't access locally using the IP address.

    Is there a config problem that I can correct?

    Thank you for any guidance.
     
  2. lankyb

    lankyb Well-Known Member

    Joined:
    Sep 21, 2004
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Peterborough, UK
    You might need to put the server's ip address(es) in the 'access hosts' section of the MySQL setup. The server might be seeing it as a unwanted server trying to access the databases.
     
  3. jondolar

    jondolar Well-Known Member

    Joined:
    Feb 15, 2004
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    I wonder if it is supposed to be there by default?

    Thanks for the tip, I'll research the setting unless you know it off-hand ;)
     
  4. lankyb

    lankyb Well-Known Member

    Joined:
    Sep 21, 2004
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Peterborough, UK
  5. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    Identity checking in MySql is performed using the three user table scope fields (Host, User, and Password). The server accepts the connection only if a user table entry matches your hostname and user name, and you supply the correct password.

    Change the value in the user table scope fields to '%'

    A Host value of '%' matches any hostname..
     
  6. jondolar

    jondolar Well-Known Member

    Joined:
    Feb 15, 2004
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    In CPanel, we've added a host of % but still the php script only works if we put localhost for the host and not the IP address.

    I don't know if this is default behaviour or if something is wrong with my setup. Can anybody confirm that they can connect to mysql using the server IP from php?
     
  7. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
Loading...

Share This Page