0

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:

include("xmlapi.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 )

3 Answers 3

3

Actually the solution here is to do this:

$xmlapi->set_port( 2083 );

You don't need to disable SSL through WHM, that's not ideal.

Sign up to request clarification or add additional context in comments.

1 Comment

Your absolutely correct. Figured that out a few days later - but thanks for pointing it out.
0

So I'm trying to create a database/user with out root access

Unless the user you are logging in with has permission to create new databases or users, then you will not be able to accomplish this.

This is true whether we're talking about the CPanel API or MySQL itself.

4 Comments

The user I'm logging in with can log into cpanel and create a database and a user. He just doesn't have root access. Is there a different permission required?
Can the user perform any actions over the API? Maybe API use itself is a permission?
There was a setting in whm only allowing ssl connections. Turned it off and worked fine.
The joy of useless error messages! Please post your solution as a new answer to this question and mark it accepted, so this question shows as having been fixed.
0

There was a setting in whm only allowing ssl connections. Turned it off and worked fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.