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.

dbmapping recreate on all users

Discussion in 'Database Discussions' started by roliboli, May 12, 2015.

  1. roliboli

    roliboli Active Member

    Joined:
    Sep 3, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Switzerland
    Hi, I created on the shell a lot of databases for different users. I know, this should be done with the API way. But nevertheless, I have now problems when transfer accounts on another server. Because the databases are not assigned to the account.

    There is the script dbmaptool which should correct the assignement from DB to the specific account. But there are a lot of users and databases on a server to fix.

    Is there another possibility to automate this process?

    I have this situation for all accounts/DBs:
    DB: username_DBNAME
    USER: username_DBUSER

    Maybe there is a "check-script" from cPanel which will detect unassigned databases and can correct them (update the yaml file).

    Thank you
    Roland
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

    There's so such script, but you can use the tool via the command line instead of the UI:

    Code:
    -bash-3.2# /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.'
    Thank you.
     
  3. roliboli

    roliboli Active Member

    Joined:
    Sep 3, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Switzerland
    Yes, I know. But that means that you have to enter the mapping for each user manually. I would be better to check the mappings on the whole server automatically.

    So each user to user_DBNAME / user_DBUSER

    Thank you
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    There are no native tools to do that as it's not possible to associate a database with an account if the database was added manually. You may want to consult with a qualified system administrator if you are looking for assistance with developing a custom script for such an action.

    Thank you.
     

Share This Page