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.

Deleting a MySQL DB via CPanel API -You do not have access to that database

Discussion in 'cPanel Developers' started by webnoob, Aug 21, 2012.

  1. webnoob

    webnoob Member

    Joined:
    Jun 3, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Hi All,

    I am creating a database using:

    PHP:
    $xmlapi->api1_query($this->apiUser"Mysql""adddb", array($this->urn));
    which is working without a problem. However, when I try and remove the database using:

    PHP:
    $xmlapi->api1_query($this->apiUser"Mysql""deldb", array($this->urn));
    I get an error: You do not have access to that database (test)!

    HTML:
    SimpleXMLElement Object
    (
        [module] => Mysql
        [func] => deldb
        [type] => event
        [source] => internal
        [apiversion] => 1
        [data] => SimpleXMLElement Object
            (
                [result] => You do not have access to that database (test)!
    
            )
    
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
    )
    
    I have tried adding a user first but get the same error.

    Any ideas how I can remove the database as well?

    p.s $this->apiUser refers to the same user I log into my Control Panel with and I don't have any issues removing the DB's via the CP.

    Thanks.
     
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Re: Deleting a MySQL DB via CPanel API -You do not have access to that data

    The database should likely be $user_$dbname rather than just $dbname.
     
  3. webnoob

    webnoob Member

    Joined:
    Jun 3, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Re: Deleting a MySQL DB via CPanel API -You do not have access to that data

    I have tried both "username_test" and "test" and it returns the same result for both.

    I assume this "should" be working with what I have?
     
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Re: Deleting a MySQL DB via CPanel API -You do not have access to that data


    How are you authenticating?
     
  5. charsleysa

    charsleysa Active Member

    Joined:
    Jul 18, 2011
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Palmerston North, New Zealand
    cPanel Access Level:
    Root Administrator
    Re: Deleting a MySQL DB via CPanel API -You do not have access to that data

    To delete a database you must prefix it with the username. I am unsure on your PHP expertise but I would like to point out that creating a string like the following will be incorrect:
    $dbname = "$username_$database";
    This is incorrect because of PHP variable naming conventions, (one of) the correct way to do it is like so:
    $dbname = $username.'_'.$database;
    This ensures no mistakes with variable naming conventions and creates the correct database name.
     
Loading...

Share This Page