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.

Remote database creation

Discussion in 'cPanel Developers' started by cagy, Jul 29, 2009.

  1. cagy

    cagy Member

    Joined:
    Jul 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hi all,

    I've looked through the API docs but couldn't seem to find what I'm looking for. I'm looking for a way to remotely create/delete/edit databases and database users using only the user's cPanel login username and password.

    I've seen a reference to "adduserdb", but didn't see it in the API docs. Here is a sample of what I saw:

    Code:
    user=$cpanel_username&xmlin=".urlencode("<cpanelaction><module>Mysql</module><func>adduserdb</func><apiversion>1</apiversion><args>".$cpanel_username."_$mysql_database</args><args>".$cpanel_username."_$mysql_username</args><args>ALL</args></cpanelaction>
    It would be fantastic if someone could point me in the right direction.

    Thanks a lot!

    Cagy
     
  2. cagy

    cagy Member

    Joined:
    Jul 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Alternatively, and perhaps a better solution, is it possible to create databases etc... from the command line if you ssh into the user's account?
     
  3. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    There is a way to do this via CLI, using one of cPanel's cPwrap scripts, this is subject to change at any time:

    Code:
    /usr/local/cpanel/bin/mysqlwrap ADDDB foobar
    Now, as for xml-api, this is undocumented and an API1 call:

    Code:
    <cpanelaction>
      <apiversion>1</apiversion>
      <module>Mysql</module>
      <func>adddb</func>
      <args>foobar</args>
    </cpanelaction>
    
     
  4. cagy

    cagy Member

    Joined:
    Jul 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Great, thanks for the info. Where can I find the documentation for mysqlwrap and any other CLI utilities?
     
  5. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Unfortunately at this time I am not aware of any such documentation, although you can strace it out of cpsrvd if you are familiar with process tracing.
     
Loading...

Share This Page