Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Oct 2001
    Posts
    90

    Default Can't connect to MySQL from PHP

    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.
    Urban Weigl
    http://hostit365.com/

  2. #2
    Member
    Join Date
    Aug 2001
    Posts
    151

    Default

    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
    Cheers,
    Nicholas Brown

  3. #3
    Member
    Join Date
    Oct 2001
    Posts
    90

    Default

    [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.
    Urban Weigl
    http://hostit365.com/

  4. #4
    Member
    Join Date
    Oct 2001
    Posts
    90

    Default

    Anybody?
    Urban Weigl
    http://hostit365.com/

  5. #5
    Member
    Join Date
    Oct 2001
    Posts
    90

    Default

    Problem solved. I had to restart the mySQL server, in addition to Apache.
    Urban Weigl
    http://hostit365.com/

Similar Threads & Tags
Similar threads

  1. Help! Can't connect MySQL after upgraded PHP 4.4.4 to 4.4.7
    By taotoon in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 04-25-2008, 02:33 PM
  2. PHP Won't connect to mySQL
    By deanstev in forum cPanel and WHM Discussions
    Replies: 8
    Last Post: 12-04-2007, 08:46 PM
  3. Php scripts cannot connect to MySQL
    By anzix in forum Database Discussions
    Replies: 8
    Last Post: 08-12-2004, 08:12 PM
  4. Replies: 0
    Last Post: 06-27-2004, 02:53 AM
  5. HELP php can't connect to mysql anymore
    By jamesbond in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 03-07-2003, 10:30 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube