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!

How to repopulate database username.yaml

Discussion in 'Database Discussion' started by Mic1, Feb 26, 2015.

  1. Mic1

    Mic1 Member

    Joined:
    Feb 26, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Since the upgrade to cPanel 11.44 and the changes in association with username/database name, setupdbmap has become deprecated.

    I have seen cases where the yaml file is a barebones file. The cPanel API is already being used for creating the databases and users.
    I need the ability to be able to auto-recreate the yaml file for a single user and/or to check and recreate for all users on the server.

    What is the new cPanel solution for fixing an empty database username.yaml file?
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,442
    Likes Received:
    1,961
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello :)

    You can use "/usr/local/cpanel/bin/dbmaptool" to update ownership of databases to specific accounts:
    Code:
    -bash-4.1# /usr/local/cpanel/bin/dbmaptool
    /usr/local/cpanel/bin/dbmaptool cpuser --type mysql|pg --dbusers 'user1, user2' --dbs 'db1, db2'
    
               These flags are treated individually. This tool will not map a virtual user to a database.
               /usr/local/cpanel/bin/dbmaptool user1 --type mysql --dbs 'db1' --dbusers 'virt1'
               /usr/local/cpanel/bin/dbmaptool user1 --type mysql --dbs 'db1' && /usr/local/cpanel/bin/dbmaptool user1 --type mysql --dbusers 'virt1'
               The above two commands are analogous; result in cpuser 'user1' having privileges for 'db1' and having a virtual user named 'virt1.'
    The YAML file should create automatically when you create a database or database user.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Mic1

    Mic1 Member

    Joined:
    Feb 26, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you for your reply.

    I'm feeling a bit short-handed with this solution.
    No databases/users will show up in cPanel. In order to properly fix this situation, I have to dig through mysql grants to find what user is assigned to what database, set them back up with the dbmaptool, and then use the cPanel api to re-add the user to the database.

    This is a very slow process when there are tens or hundreds of users to put back together again. Is there no other, more complete solution?
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,442
    Likes Received:
    1,961
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Could you elaborate on how the databases/database users were removed from the account? It might be better to address the source of the problem as opposed to trying to manually resolve the issue for each account.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Mic1

    Mic1 Member

    Joined:
    Feb 26, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    At this point the source of the problem is unknown. There are no related errors. All the users/databases were added to cPanel using the API and, shortly after the upgrade to 11.44, they've just gone missing, with no rhyme or reason.
     
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,442
    Likes Received:
    1,961
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Mic1

    Mic1 Member

    Joined:
    Feb 26, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    An in-house tool is being created to fix these. This tool is also important since, in addition to the above, I need to be able to migrate accounts, which involves some things that won't work with an API in every instance.

    Thank you for your time and help, Michael. It's much appreciated.
     
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