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.

Database Creation WITHOUT root access?

Discussion in 'cPanel Developers' started by rewq007, Apr 9, 2011.

  1. rewq007

    rewq007 Registered

    Joined:
    Apr 9, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    So I'm trying to create a database/user with out root access. It's either not possible - or i've done something wrong.

    Suggestions? Missing a Step?

    Here is my code as of now:

    PHP:
    $xmlapi = new xmlapi($db_host);   
    $xmlapi->password_auth("".$cpaneluser."","".$cpanelpass."");   
    $xmlapi->set_debug(1);//output actions in the error log 1 for true and 0 false 
    $xmlapi->set_output('array');//set this for browser output 
    //create database   
    $createdb $xmlapi->api1_query($cpaneluser"Mysql""adddb", array($databasename));  
    //create user
    $usr $xmlapi->api1_query($cpaneluser"Mysql""adduser", array($databaseuser$databasepass));  
     
    //add user
    $addusr $xmlapi->api1_query($cpaneluser"Mysql""adduserdb", array("".$cpaneluser."_".$databasename."""".$cpaneluser."_".$databaseuser.""'all'));   
    Doing a print_r of any of the calls just tells me Array ( [data] => Array ( [result] => 0 [reason] => Access denied )
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi rewq007,

    When using the XML-API to perform API1 or API2 queries, authenticated as the cPanel user (and not root), then you must use the cPanel ports (2083 or 2082).

    By default the PHP XML-API client class use port 2087. So I think the following shoul work for you:
    PHP:
    $xmlapi = new xmlapi($db_host);    
    $xmlapi->password_auth("".$cpaneluser."","".$cpanelpass."");    
    $xmlapi->set_debug(1);

    // auth'd as user, must use cPanel port
    //   set to 2083 for https or 2082 or http

    $xmlapi->set_port(2083);  

    //PS.  you will have to use 2082 if you don't have cURLSSL or OpenSSL compiled in you PHP binary
    Regards,
    -DavidN
     
  3. rewq007

    rewq007 Registered

    Joined:
    Apr 9, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Appreciate the response. Very late last night I decided to go digging around my WHM settings and it appeared that it was only accepting SSL connections under 'tweak settings -> security'. Turned that off and connected just fine.
     
Loading...

Share This Page