0

I'm trying to create a copy of an existing database via a php script on a shared hosting account (specifically Bluehost.com). I can't get the CREATE DATABASE command to work, I tried a few variations of this script: How To Programmatically Create MySQL Databases on Shared Linux Hosting Plans, and the support people say that you can't create a database outside of cpanel. I'm wondering if this is truly the case or if anyone has a way of doing it. I can use phpmyadmin to copy the database, but I really need to automate this process so it can be run by a script on the site.

Thanks in advance for any help!

Community
  • 1
  • 1
dvanderb
  • 757
  • 2
  • 8
  • 20

2 Answers2

2

Your user account will not have create database privileges. If it did a rogue customer could create hundreds of databases on the server thus severly impacting performance for themselves and other users.

The cPanel will run the CREATE database on your behalf as a user with sufficient privileges granted to create a database.

Alan Savage
  • 822
  • 1
  • 12
  • 24
1

I'm guessing you have to pay for another database...the CREATE grant is likely disabled for customers, or you'd be getting services for free.

AJ.
  • 27,586
  • 18
  • 84
  • 94
  • The account comes with unlimited databases, but i'm guessing you're correct in that the 'CREATE' grant is disabled. However, I could still create the same number of databases...it's just going to be more annoying as a manual process. – dvanderb Apr 20 '11 at 19:26
  • @user532887 - contact your host and explain your requirements. They **may** make an exception for a single customer if you have an agreement with them in place. IOW, it's possible for them to grant **just you** with CREATE privs. – AJ. Apr 20 '11 at 19:28