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.

dbmaptool: DB is already owned by USER

Discussion in 'Database Discussions' started by Islandhosting, Jul 11, 2016.

  1. Islandhosting

    Islandhosting Member

    Joined:
    May 15, 2015
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Canada
    cPanel Access Level:
    Root Administrator
    Twitter:
    An account creates a MySQL db and user through the normal cPanel interface and they both show up in the cPanel interface.

    Then the account deletes both of them and they are gone from the cPanel interface.

    Then a command line tool attempts to create the same database and user. It's successful (they exist and can be accessed), but the database and user don't show up in the cPanel interface.

    So I use dbmaptool as follows:

    /usr/local/cpanel/bin/dbmaptool CPUSER --type mysql --dbusers DBUSERNAME

    And that works, so now the username shows up in cPanel, so then I do this:

    /usr/local/cpanel/bin/dbmaptool CPUSER --type mysql --dbs DBNAME

    And it gives me the error "DBNAME is already owned by CPUSER" and it still doesn't show up in the cPanel interface.

    It seems that either something is being left behind when a database is deleted from within the cPanel interface, or there is a bug in the dbmaptool that makes it think the database is still owned by an account.

    I need to be able to recreate the database and map it to a user even if it previously existed.

    Any thoughts?
     
  2. Islandhosting

    Islandhosting Member

    Joined:
    May 15, 2015
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Canada
    cPanel Access Level:
    Root Administrator
    Twitter:
    Seems to have been fixed by also running /usr/local/cpanel/bin/dbindex
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    The user's JSON file is updated immediately, when the database is created or removed. However, the /var/cpanel/databases/dbindex.db.json file isn't updated in real time, instead it's updated by the following "root" cron job:

    Code:
    15 */2 * * * /usr/local/cpanel/bin/dbindex >/dev/null 2>&1
    Could you let us know the specific method you are using to create the database and database user through the command line?

    Thank you.
     
  4. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Hello...

    WHM 60.0 (build 24)

    I also seem to have this issue, however I am not trying to recreate a database, I am trying to have another user/account owner it which seems to the the reason for the tool.

    "The Database Map Tool allows you to assign ownership of databases and database users to specific cPanel accounts."

    I go into WHM and into the Database Map Tool.
    I select the account to whom the database should be owned by.
    In the Database Name box I enter in the name of the database I want the selected account to own.

    "DATABASE is already owned by USERNAME" (Which is TRUE as that account is still active.)

    I did the same thing for users I wanted to move, and it did not actually MOVE them, it duplicated them into the new account.

    Per the tools description it should allow me to assign ownership.

    Please help.


    Side Note...The help doc on how to use it is incorrect. Look step #4 and #5, they are clearly wrong.

    Database Map Tool - Documentation - cPanel Documentation

    4. In the Database users text box, enter a comma-separated list of databases that you wish for the cPanel user to own.
    5. In the Database names text box, enter a comma-separated list of database users that you wish for the cPanel user to own.

    Should be...

    4. In the Database users text box, enter a comma-separated list of database users users that you wish for the cPanel user to own.
    5. In the Database names text box, enter a comma-separated list of databases that you wish for the cPanel user to own.
     
    #4 BottNet, Nov 17, 2016
    Last edited by a moderator: Nov 18, 2016
  5. divemasterza

    divemasterza Member

    Joined:
    Feb 2, 2013
    Messages:
    16
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    South Africa
    cPanel Access Level:
    Root Administrator
    Twitter:
    Same here...
    Code:
    root@geekshack2 [/var/cpanel]# /usr/local/cpanel/bin/dbmaptool capilisco --type mysql --dbs newstrad_civicrm
    newstrad_civicrm is already owned by newstrad
    Highly annoying as I need to delete the newstrad account and assign the database to another user
     
  6. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    In my case, I CAN NOT remove the current user as it is still being used. I switched community software I used but wanted to keep the old site active so I could reference it if I needed to. So I made a new account for it and moved all the old site to it and just need to make the database be owned by the right account.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    The Database Map tool is intended to assign unaffiliated databases and database owners to existing cPanel accounts. It's not designed to transfer ownership of databases or database usernames from one cPanel account to another.

    A condition where the database index was not updated immediately after a database creation that allowed this behavior in the past was corrected in cPanel version 58:

    Fixed case CPANEL-6587: Update database index when creating a MySQL database.

    The recommended solution for transferring databases from one account to another is to backup the databases, remove them from an existing account, and then restore them to the new account. Or, to reduce downtime, backup the database, and upload it to the new account under a different database name.

    I've opened a case with our documentation team to ensure Database Map Tool is updated to reflect this information, and to correct the syntax under steps 4 and 5.

    Thank you.
     
  8. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Hi...

    Thank you kindly for the reply. Clearly, that is not what the tool states and thus, yes, should be updated to reflect the right information.

    The solution is not ideal as you are talking about large databases that would take a very, very long time to export and import. After all, the databases are just fine and just WHM needs to updated to know what account should have control over them. This does not sound like it should be an issue like this at all seeing if I were to remove the account, I could map the database to someone else. So why would you not be able to do so regardless?

    Is there no other way to map it to the right user? IE...Could you remove some files or something that is used to map them and then just remap them using the tool thus remaking the files?

    Thank you Michael.
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Unfortunately, there are no custom workarounds to offer to make this tool transfer databases from one account to another. One alternate solution, if the size of the database is the drawback to manually moving the database, is to backup the destination account, terminate it, and then add it as an addon domain name to the account with the database you want to move. At that point, you could use the following option to convert the addon domain name to it's own account (with the database):

    Convert Addon Domain to Account - Documentation - cPanel Documentation

    You'd then only have to restore the aspects of the account that you terminated from the backup (website files, emails, etc), as opposed to the large database.

    I recommend opening a feature request if you'd like to see that functionality considered for a future version of cPanel:

    Submit A Feature Request

    Thank you.
     
  10. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Thanks...however I think I think that would also take the new database that was made for the conversion with it as it would also be assigned to the account. (Unless it allows for you to select databases to move with it.) And if you can, then surely it is possible to change the account a database belongs to.

    Thank you again Michael.
     
  11. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Augh...I tried to make the feature request and it allows me to start a new one, however when I go to submit, it asks me to login and it fails every time yet it allows me compose.

     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You can choose to "Move" or "Copy" any existing databases from the source account when using this feature.

    Could you click "Login", then choose the "Register" tab to see if that allows you to create a new account?

    Thank you.
     
  13. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Looks like it took my new registration even though it reads when you go to the link you provided...

    You've been automatically registered on the cPanel Feature Requests System!

    As a registered user of the cPanel Community Forums, you have been automatically logged into the cPanel Feature Requests System by visiting this page. You should not need to register on the cPanel Feature Requests site to contribute and get involved, we've taken care of that for you here. Your cPanel Community Forum login details are now tied to the Feature Requests site. You can use the link on top of any page of the forums to access the Feature Requests site directly from now on. Thank you visiting this page! If you're looking for an introduction to the new Feature Requests site, you'll find that below.

    ...So something is not right somewhere as it clearly did not work and allowed me to register with the same address. I did get the email and registered.

    I have now made the request which is in moderation.
     
  14. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Thank you for taking the time to open a feature request. Feel free to post the link here once it's approved by one of the moderators for visibility to anyone visiting this thread for the first time.

    Our documentation team has completed the changes to the Database Map Tool document, and the changes are planned for publication in the near future.

    Thank you.
     
  15. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Your welcome Michael. And Thank YOU for the support you all give.

    I will post the link once it is approved. (Hope I get a not on it or I surely will forget. :))
     
  16. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Hi Michael...

    Well, this sounded like a good idea, however it requires me to take out another domain to do it. (Unless I can fake it somehow because it goes to look up the address to see if it is valid.) I tried using oldsite.currentdomain.com and it says I can not park it on top of itself. (That is what sub domains are for.)

    So do you know of a way I can fake it to I can make the add on domain and then do what we need to do to convert it to an account?

    I was trying to make a url like oldsite.domain.com using make new account (Thus really a sub domain but with a real account.) The reason, as I think I mentioned, was that then I did not need to back it up each night.

    Hope all that made sense. :)
     
  17. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello @BottNet,

    You could temporarily enable the following options under the "Domains" tab in "WHM >> Tweak Settings":

    Allow Remote Domains
    Allow unregistered domains

    Thanks.
     
  18. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    cPanelMichael likes this.
  19. BottNet

    BottNet Member

    Joined:
    Jun 25, 2015
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Rochester, NY
    cPanel Access Level:
    Root Administrator
    Hi...

    Ok, I made a fake domain as an add-on. I then turned it into an account while taking the database with it. I then went into WHM and changed the domain name from the fake one to be the one I wanted so it would work.

    So...I did finely get it done. But it should would have been much easier if WHM could just change the owner. :)

    Thank you Michael for your help.
     
  20. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I'm happy to see the workaround worked well. I also voted for the feature request, and encourage anyone else that wants the same feature after reviewing this thread to vote and add feedback to it.

    Thanks!
     

Share This Page