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.

Mysql connection problem on a domain

Discussion in 'General Discussion' started by black&white, Apr 24, 2008.

  1. black&white

    black&white Well-Known Member

    Joined:
    Aug 10, 2004
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    i have a simple script to connection to Mysql:

    <?

    $db_host = 'localhost';

    $db_user = 'user_demo';

    $db_password = 'test';

    $db_name = 'user_demo';

    $connection = mysql_connect($db_host,$db_user,$db_password)or die("Warning! Connection problem: " . mysql_error());
    print ("Connected! ");

    if ($connection == FALSE)
    die ("Connection problem");

    mysql_select_db($db_name, $connection)
    or die ("Connection problem");

    mysql_close($connection);

    ?>


    It works correctly but on an specific domain it shows this error:

    Error on db selection.

    Why that? I have created the db without errors and added user with privileges.

    Please help me to fix this issue.

    Thank you
     
  2. DaveUsedToWorkHere

    DaveUsedToWorkHere Well-Known Member

    Joined:
    Dec 28, 2001
    Messages:
    689
    Likes Received:
    1
    Trophy Points:
    18
    Can you connect to the database from the shell?


    mysql --user=user_name --password=your_password db_name
     
  3. switzine

    switzine Member

    Joined:
    Jul 9, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    Please execute the following command from your root mysql.

    1) GRANT ALL privileges ON user_demo.* TO 'user_demo'@'localhost' identified by 'test';

    This should help.

    cheers

    :)
     
Loading...

Share This Page