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.

Can't connect to MySQL from PHP

Discussion in 'General Discussion' started by avara, May 27, 2002.

  1. avara

    avara Well-Known Member

    Joined:
    Oct 28, 2001
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    I get an error along the lines of the following when I try to connect to MySQL from PHP:

    &Warning: MySQL Connection Failed: Host 'server.host.name' is not allowed to connect to this MySQL server in /home/user/public_html/scriptname.php on line X
    Unable to connect!&

    Silly me forgot how to fix this however. Yes I did check /etc/hosts and make sure that 127.0.0.1 localhost localhost.localdomain was in the first line, so that can't be it.
     
  2. Brownie

    Brownie Well-Known Member

    Joined:
    Aug 10, 2001
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    try using [b:94bae67ca4]localhost[/b:94bae67ca4] instead of [b:94bae67ca4]server.host.name[/b:94bae67ca4] to connect to MySQL....i doubt the database is set to accept connections from other than user@localhost or user@customersdomain.com
     
  3. avara

    avara Well-Known Member

    Joined:
    Oct 28, 2001
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    [quote:7dfa560a76][i:7dfa560a76]Originally posted by Brownie[/i:7dfa560a76]

    try using [b:7dfa560a76]localhost[/b:7dfa560a76] instead of [b:7dfa560a76]server.host.name[/b:7dfa560a76] to connect to MySQL....i doubt the database is set to accept connections from other than user@localhost or user@customersdomain.com[/quote:7dfa560a76]

    I am actually using &localhost& in the script to connect, however it still returns server.host.name in the error. I had the same problem on another new installation of WHM, and it could be fixed by editing a config file. I can't remember how I did it though.
     
  4. avara

    avara Well-Known Member

    Joined:
    Oct 28, 2001
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Anybody?
     
  5. avara

    avara Well-Known Member

    Joined:
    Oct 28, 2001
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Problem solved. I had to restart the mySQL server, in addition to Apache. :)
     
Loading...

Share This Page