The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL Database Creation

Discussion in 'cPanel Developers' started by thearchitect, Oct 16, 2009.

  1. thearchitect

    thearchitect Registered

    Joined:
    Oct 16, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Is there a way to allow a hosting account user to create a MySQL database programmatically with a SQL statement?

    At the moment phpMyAdmin for all the hosting accounts is showing 'No privileges' under Create Database. I assume that this is locked down by WHM.

    Anyone have an idea how to address that issue? We are running our own server, so we can configure anything in WHM the way we want to.

    Thanks,

    JB
     
  2. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    You can assign the privileges to the database from the cPanel. You will have to login to your cPanel account and under MySQL click on your database and assign the privileges.
     
  3. thearchitect

    thearchitect Registered

    Joined:
    Oct 16, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for your response and yup, that would be the way to change privileges for an already existing database.

    What I am after though is changing privileges for a user account to be able to create databases from within MySQL with a CREATE DATABASE command. That seems to be disabled through WHM. So I am looking for a way to doing that.

    The issue is that I need to create databases dynamically from within my PHP class. The database user I am connecting to the database with doesn't seem to have the privileges to do so.

    Trying to add the database creation privileges to the database user account I can do temporarily, but they seem to get reverted back by some process within cPanel or WHM. So, I am still looking for some setting in WHM that would allow me to pull this of.

    Thanks,

    JB
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    cPanel/WHM does have APIs for creating database users and databases. While this isn't the same as using the CREATE DATABASE command in SQL, it can be automated using PHP. We have already assembled a PHP class for interfacing with our APIs which is available at: http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v.0.1.tar.gz

    I'm moving this post to our Developer Discussions forum since you may receive more relevant responses there.
     
Loading...

Share This Page