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!

1
  • you can check what permissions you have on the database with show grants for user@host; Commented Apr 20, 2011 at 19:30

2 Answers 2

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.

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

Comments

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.

2 Comments

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.
@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.

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.