zubrag.com
Free php and cpanel scripts to automate your daily routine

Free PHP Scripts :: cPanel Database Creator

cPanel does not allow you to create databases directly from MySQL/PhpMyAdmin on cPanel webhosting. You would have to login to cPanel and use its interface to create database each time you need a new one.
cPanel Database Creator will make this process much easier. In order to create a database on your hosting server you just need to run this script from browser, shell, or cron job, passing database name as parameter.

Before using this script you will need to update it with cPanel username, password, and host name (domain or IP).

Usage: cpanel_create_db.php?db=database-name&user=username&pass=password
where database-name should be replaced with a database name to be created on your hosting server.
Database Creator will also create a database user and assign it to the database with ALL permissions. Script will not create database user if you omit the user parameter. In this case usage would be cpanel_create_db.php?db=database-name

Note: if script does not work try running it via cURL. This requires cURL installation on the server. Default cURL path is set to /usr/bin/curl. Feel free to change it in the script code if cURL path is different on your hosting server.

Download cPanel Database Creator


Comments

Peter July 16, 2006
Cool script!

Thanks
October 4, 2006
pretty
mrprez [anti-spam] gmail.com October 28, 2006
How do you create the user and grant priveleges?
October 31, 2006
Does not work pity
November 12, 2006
Second, that... does not work.
November 12, 2006
Sorry! It does work... I cant spell my own domain name. However its not much use if you cant assign users to the db
zubrag November 13, 2006
As stated above it will not work if cURL is not installed. We'll change it to work without cURL soon. Please post your requests on the forum, so we could discuss and fix. This page is not a good place for discussion. Thank you!

http://www.zubrag.com/forum/
justin November 28, 2006
well, i would go to the forum to talk about it, but no threads there about it. already looked. please let me know when you will have a version that doesnt require cURL, and that will work on any other host that is cpanel or not. thanks
delacreation [anti-spam] delacreation.com December 11, 2006
Please i need hepl!!!
i can not access to mysql Db
December 24, 2006
VERY cool script. Thanks!!!!!!!
reece December 28, 2006
i had a problem with not being able to create databases with cpanel and this workd perfectly

Thanks
April 26, 2007
when i create database it's work but
assign user to database is NOT WORKING

Thanks
poonam April 30, 2007
thanks....this script allows me to create database but...script dont assign user to new created database...please help ...its urgent.
networkofemail.com July 14, 2007
We have a ton of domains and it's a real pain always logging in to various domains to create databases. Especially if each domain needs the same script instealled and we have to create databases for them all.

Instead of hard-typing the domain name and password in to the file, you should make it so that you can specify the domain name and the cpanel password on the fly for the particular domain domain you're about to work with. After that, you specify the database name, user name and password for the domain you're working with.

You should do the same with all of your scripts, particularly e-mail account creator and forwarder, which I'm glad we found.

Thanks for your work!
wangfeel July 22, 2007
escapeshellarg made changes on $db_name, that's why you cannot assign the user to db, keep the original $db_name, you will get your result.
Share views with me by wangfeel at gmail dot com
August 21, 2007
the script only creates the user the first time i run it, if i reload the page it then creates the database and adds the user to it. cant figure out the issue.
vitormsousa [anti-spam] gmail.com October 28, 2007
very nice script!!! it´s very interesting.
cmstom [anti-spam] gmail.com November 28, 2007
Warning: exec() has been disabled

and host do not want to enable it. What can we do ?
gregory December 29, 2007
yes, i had the same issue as wangfeel the escapeshellarg() was adding html escaped quotes around my database name so the user wasn't getting added to an actual existing database. Other than this issue, this script works great! thanks for writing
March 7, 2008
Yea the escapeshellarg() is preventing the user from being added. This is an awesome script and I am very greatful
emekingsley [anti-spam] yahoo.com March 19, 2008
Thanks man
miketee July 2, 2008
Had some little issues with the script on my server. As mentioned above, the escapeshellarg() function in line 49 screws up the database name, adding single quotes to it. Eg database domain_wtf becomes domain_'wtf'.

To anyone interested, I have provided an update to the cpanel_create_db.php script here: http://www.mediafire.com/?ku7m11ej0jd
bullbutter [anti-spam] gmail.com July 29, 2008
thanks miketee, your version works wonders on my server. thanks
ankitpratap2005 [anti-spam] yahoo.com August 29, 2008
I got the script that I require.and it is working perfectly
class servers September 18, 2008
thanks - great script.

classservers.com
mihai1302 [anti-spam] yahoo.com September 23, 2008
It works perfectly.
bunda1302 [anti-spam] yahoo.com September 29, 2008
Mihai is correct, it works perfectly!!!
jigu March 19, 2009
hello
fritzroy15 [anti-spam] yahoo.com April 17, 2009
17 April 2009: For any 404 errors: On line 52, where you have http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name, there is no file named adddb.html, only addb.html, so in case you're getting a 404 not found, this is why.
Simply delete one 'd' so you are left with
http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addb.html?db=$db_name
drew [anti-spam] buzzybeemarketing.com September 5, 2009
I found the problem. There is an extra d in the adddb.html path. The correct path is addb.html (only two d's)
jr2delgado [anti-spam] yahoo.com September 10, 2009
Sory but http://www.zubrag.com/downloads/cpanel_create_db.zip

down load link do not work
Viery November 5, 2009
The script is not assigning user to the created database. Please help. How do I fix this.
Nik January 5, 2010
This doesn't create database, only user.
Can you fix it please.
greg August 20, 2010
Can this be run remotely from another server you own to a server you don't own
ben September 18, 2010
If you having trouble getting it to create a user try using a very short user name. like bob. I found that the prefix my host adds to all my usernames was causing them to not be created.
mail2shivram [anti-spam] gmail.com October 21, 2010
it is not working. from one credencial to another. related cpanel.
thomas October 23, 2010
I am trying to mess with this script. My web host has execCommand() disabled. Is there anyway to make this work without using execCommand()?
ankit [anti-spam] yahoo.com November 9, 2010
does not work.
Robert December 17, 2011
If it's not working for you and you get an error that looks like

"not able to find the document (./frontend/x3/sql/adddb.html)"

change file to addb.html on

"$result = execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addb.html?db=$db_name");"
Derrick http://Ecommerce.Matrix-E.com February 24, 2012
On my shared host, I made the below 2 changes to make the script work:

line 49 - do not use escapeshellarg()
$db_name = $_GET['db'];
$db_name = escapeshellarg($_GET['db']);

line 52 - addb.html < adddb.html
$result = execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addb.html?db=$db_name");
$result = execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name");

Hope this help someone else!
Derrick

-
Error messages were:

There was a problem adding the user. Show Details
Error from cpmysql wrapper: You do not have access to that database (cpaneluser_&#39;dbname&#39;)!

Create MySQL database
There was a problem creating the database.. Show Details
“<span class="status">cpaneluser_'dbname'</span>” is an invalid database name. It contains invalid characters.
admin [anti-spam] tabz.co.cc May 5, 2012
Hi Guys i have hostgator whm account and iam trying to excute the file but i only get the Usage: cpanel_create_db.php?db=database-name&user=username&pass=password

Can someone help me install that please ill be glad to donate and pay .
thanks please pm me
safetweak [anti-spam] yahoo.com May 22, 2012
it works on hostmonster and inmotionhosting!! of course with a little modifications.. tested on may 22th 2012.. great thanx you rocks!!
williamsjohn647 [anti-spam] yahoo.com August 20, 2012
hello how are you
sanjay September 7, 2012
"http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name")
this command givied me 'HTTP request failed! HTTP/1.1 401 Access Denied ' error. i have used the correct password and username for connecting. And i am able to create the database when i give this url(url in this format) in a browser. What is the problem...?
October 3, 2012
Same problem as sanjay when posting following url:cpanel_create_db.php?db=dynamicdb
error:
:HTTP/1.1 401 Access Denied"
I am using curl.
November 18, 2012
FYI, the correct page in cpanel is addb.html not adddb.html
raja [anti-spam] tritonitsolutions.com January 3, 2014
I`m getting below error what can i do??
Warning: file_get_contents(http://...@tritonitsolutions.com:2082/frontend/x/sql/adddb.html?db=eco): failed to open stream: HTTP request failed! HTTP/1.1 401 Access Denied in /home/aptitude/public_html/tritonitsolutions.com/subdomain/cpanel_create_db.php on line 46

Warning: file_get_contents(http://...@tritonitsolutions.com:2082/frontend/x/sql/adduser.html?user=eco&pass=pass123!@#): failed to open stream: HTTP request failed! HTTP/1.1 401 Access Denied in /home/aptitude/public_html/tritonitsolutions.com/subdomain/cpanel_create_db.php on line 46

Warning: file_get_contents(http://...@tritonitsolutions.com:2082/frontend/x/sql/addusertodb.html?user=aptitude_eco&db=aptitude_eco&ALL=ALL): failed to open stream: HTTP request failed! HTTP/1.1 401 Access Denied in /home/aptitude/public_html/tritonitsolutions.com/subdomain/cpanel_create_db.php on line 46
jignesh [anti-spam] siliconleaf.com August 28, 2014
superb
manishjetly [anti-spam] gmail.com December 29, 2014
Thanks for the great script. The only issue is how to handle session cpsess4417598458 value in url.
December 29, 2015
Cant the script be used with vDeck?
programacion [anti-spam] zunfeld.com April 27, 2016

Warning: file_get_contents(http://...@chkte.com:208/cpsess603494014/frontend/x/sql/adddb.html?db=aaaa): failed to open stream: Connection refused in /home/chkte/public_html/services/BDAuntomatica/cpanelcreate.php on line 44

Warning: file_get_contents(http://...@chkte.com:2082/frontend/x/sql/adduser.html?user=bbb&pass=ccc): failed to open stream: HTTP request failed! HTTP/1.0 401 Access Denied in /home/chkte/public_html/services/BDAuntomatica/cpanelcreate.php on line 44

Warning: file_get_contents(http://...@chkte.com:2082/frontend/x/sql/addusertodb.html?user=chkte_bbb&db=chkte_aaaa&ALL=ALL): failed to open stream: HTTP request failed! HTTP/1.0 401 Access Denied in /home/chkte/public_html/services/BDAuntomatica/cpanelcreate.php on line 44
aho [anti-spam] sakata.com June 6, 2016
great
samprog4u [anti-spam] gmail.com August 25, 2016
The script did not bring any error nor message, Please help. I try curl and without curl.
harman [anti-spam] abacusdesk.co.in May 30, 2017
this script work done successfully but privileges not set of database.Please help me
pandeys465 [anti-spam] gmail.com February 3, 2020
this work for me.
two changes i made.
1:changed port number to 2083.
2:changed adddb.html to addb.html.
business [anti-spam] digitalcrazy.biz May 31, 2020
variable = "protocol://cpluser:" . urlencode(urldecode('cplp@s$word'))."ATdomain:port/frontend/skin/sql/addb.html?db=dbsuffix"
This now works a dream every time.
1. Where cpanelpassword contains special characters just enclose the password in single quotes.
2. Where cpanelpassword a dynamic variable, first urldecode, then urlencode the variable before the whole addb.html (not adddb.html) path is sent to your file_get_contents function.
3. Use https with port 2083, or http with port 2082.
4. Same as above with adduser.html and addusertodb.html but remember to add &privileges=ALL to the querystring (not &all=ALL as I see listed incorrectly).
With tweaks here and there I find these scripts awesome even 12 years later.