SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Host is not allowed to connect to this MySQL server.

    Hi Friends,

    I have created an user in phpmyadmin in hosting server & when I upload & trying to open that page I am getting this warning.

    Warning: mysql_connect() [function.mysql-connect]: Host 'xxxxxxxxxx.com' is not allowed to connect to this MySQL server in /home/xxxxxx/xxxxxx/config.php on line 7

    It is working in my local system bt nt working in hosting server. If anyone have any idea kindly help me to short out this issue.

    Regards,
    Premashish

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,195
    Mentioned
    71 Post(s)
    Tagged
    3 Thread(s)
    The host tends to be localhost if your code is on the same server as your code.

  3. #3
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried this also i got this error:
    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'xxxxx'@'localhost' (using password: YES) in /home/xxxxxxxx/xxxxxx/config.php on line 7

    If i remove the password, i got
    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'xxxxx'@'localhost' (using password: NO) in /home/xxxxxxxx/xxxxxx/config.php on line 7

    Its not in my local system, its a hosting server so here i think i have to give host name as server.

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,195
    Mentioned
    71 Post(s)
    Tagged
    3 Thread(s)
    I belive you only need to give the host name if connecting to another server. I only ever use localhost on the servers I use.

    Have you changed the passwords in your connection code to the same as the user you setup? On some setups the username will be prefixed with the usrename of the server along with the database names.
    So if your password was world and your server login was hello then your password would be hello_world.

  5. #5
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have that one also & now also I am getting same error.

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,813
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Have you tried asking your hosting provider? Or checked their online documentation/wiki? I know for the host I use, I have to setup the mysql domain name, then grant a mysql user access on that domain.

  7. #7
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have added this code

    GRANT ALL PRIVILEGES ON database_name*.* TO user_name @"%" IDENTIFIED BY "password";
    FLUSH PRIVILEGES;

    then I am getting this error

    Parse error: syntax error, unexpected T_STRING in /home/xxxxxxx/xxxxxx/xxxxx.php on line 8

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,813
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    That is a step in the right direction. As now it seems you have a syntax error in your PHP file on line 8. Check that your string has the correct opening and closing quotes, a semi-colon, etc.

  9. #9
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am getting this error, in this code everything is looking correct, I am nt able to find the error, pls help me to solve this issue.

    Parse error: syntax error, unexpected T_STRING

    GRANT ALL PRIVILEGES ON database.* TO 'user' @'%' IDENTIFIED BY 'password';
    FLUSH PRIVILEGES;

  10. #10
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,813
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    We need to see the first 10 lines of the file /home/xxxxxxx/xxxxxx/xxxxx.php

    It is hard to tell you what to fix without seeing the php syntax.

  11. #11
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the complete database connection code & I got the error

    Parse error: syntax error, unexpected T_STRING in /xxxxxx/xxxxx/xxxxxxx/xxxxxx.php on line 8

    ie.

    <?php

    $mysql_hostname = "xxxxxxxx";
    $mysql_user = "xxxxxxxxx";
    $mysql_password = "xxxxxxxxxx";
    $mysql_database = "xxxxxxxxx";

    grant all privileges on $mysql_database.* to $mysql_user@'%' identified by $mysql_password;
    flush privileges;

    $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("There is some thing wrong in database connection");
    mysql_select_db($mysql_database, $bd) or die("Some thing went wrong");

    ?>

  12. #12
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,813
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, you can't grant the privileges that way. You need to run that through phpMyAdmin or directly connected to the mysql server via SSH.

    Otherwise, you would need to be able to connect to mysql to run the query (of which you are unable to do at this point in time).

  13. #13
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can u tell what are the step for this & where I have to do this?

  14. #14
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,813
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    I would try contacting your host, the steps are going to vary greatly to what I do at mine.


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
  •