Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    51
    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:
    51
    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 Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    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>
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. cagy

    cagy Member

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

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. rajuru

    rajuru Active Member

    Joined:
    Nov 13, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    151
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice