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.

How to create MySql Database for a cpanel account via SSH ?

Discussion in 'General Discussion' started by rohan_, Apr 5, 2012.

  1. rohan_

    rohan_ Member

    Joined:
    Jun 4, 2011
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I want to know this thing, How to create new database for a existing cpanel account by using SSH ?

    Please Help
    Thanks
     
  2. JayFromEpic

    JayFromEpic Well-Known Member

    Joined:
    Apr 2, 2011
    Messages:
    204
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Scottsdale, AZ
    cPanel Access Level:
    Root Administrator
    Hmm, I never heard of making a database in ssh for an actual individual account. If anyone knows how to do this, please let us both know. This could make things a lot easier. I just always thought it would be easier to go right through cPanel. But then again, if you can do it in cPanel, there has to be a command behind it.
     
  3. Brian

    Brian Well-Known Member

    Joined:
    Dec 1, 2010
    Messages:
    117
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    There isn't a single command in which to do this. However, you could...

    [1] Create the MySQL database as normal via CLI (just as you would on a regular machine that doesn't have cPanel installed)
    [2] Map the DB using cPanel's CLI tool so cPanel & WHM is appropriately aware of its ownership via:

    Code:
    /usr/local/cpanel/bin/dbmaptool <cpuser> --type mysql --dbs '<dbname>'
    
    Example:
    /usr/local/cpanel/bin/dbmaptool jdoe --type mysql --dbs 'jdoe_forum'

    The same can be said for mapping database users. Just run /usr/local/cpanel/bin/dbmaptool on its own for further usage instructions.

    Note that this mapping tool is also available directly through WHM.

    WHM -> Database Map Tool

    In my opinion, though, this tool is best left for complex migrations or recovering the server from catastrophic failure when you don't otherwise have full backups.

    I would instead recommend using the cPanel API to create the databases.

    Mysql Module Documentation

    This will assure you're letting cPanel create everything for you. You will also have the option of being able to be run it with just the cPanel user/pass instead of requiring the command be run direct as root at CLI. If it were me, I'd be using the API.
     
    #3 Brian, Apr 5, 2012
    Last edited: May 2, 2012
Loading...

Share This Page