how to create mysql DB on shared hosting using php script


Jan 18, 2021
cPanel Access Level
Website Owner
I need to create a NEW MySQL database, NEW Table, and add users using php script.
I am using Go Daddy Shared Hosting with cPanel Deluxe..

I read that I will need to use UAPI, or XML API or something like that..

I have xmlapi.php in the same directory as my test php file.

I also read that Go Daddy Shared hosting does not allow this to work?

Can anyone help ?


$db_host = '';
$cpaneluser = 'cpanelusername';
$cpanelpass = 'cpaneluserpassword';

$databasename = 'testdb';
$databaseuser = 'newdbuser'; // Warning: in most of cases this can't be longer than 8 characters
$databasepass = 'password'; // Warning: be sure the password is strong enough, else the CPanel will reject it

$xmlapi = new xmlapi($db_host);
$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'));
Last edited by a moderator:


Jurassic Moderator
Staff member
Oct 19, 2014
cPanel Access Level
Root Administrator
Hey there! We actually have an older thread with a good example of this work here, so I'd recommend checking that out to see if that helps your situation:

I'm not sure what restrictions GoDaddy may have on your account as that is something you'd need to speak with them about, but let me know if you need anything else!