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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Existing database user can't be found

Discussion in 'Database Discussions' started by jndawson, Aug 18, 2017.

  1. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    167
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    Our customer, on his dedicated cPanel server, decided to manage databases and somehow screwed things up. He dropped in a database and used a combination of phpmyadmin and cli, and eventually whm to name the dB and the user. Nothing worked and he asked us to repair it and make it work.

    First step was to remove the dB w/ phpmyadmin. We started to create a new account for him with the intention of creating the dB via cPanel, then adding the tables via phpmyadmin - always worked great in the past.

    Apparently, customer used the mapping tool to try to get his dBuser mapped to the non-cpanel created dB. When setting up the account, error message explained that the dBuser already exists.

    We removed the user from mysql.user and the related entries in mysql.db via phpmyadmin.

    Still get the error. WHM mysql management panes don't even show the user.

    Where does cPanel store dB usernames so we can remove it?
     
  2. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    167
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    After more poking around, found these files in /var/cpanel/databases/, which I assume can just be removed:
    dBuser.json
    grants_dBuser.cache
    grants_dBuser.yaml

    The dBuser is also listed in:
    users.db
    users.db.cache

    What will break when we delete the files and remove the dBuser from the .db files?
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,220
    Likes Received:
    1,376
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You should be able to map the database user to the existing cPanel account using "WHM >> Database Map Tool". Once you do this, you can delete the database user via the "MySQL Databases" option in cPanel. Can you verify if that's not working?

    Thank you.
     
  4. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    167
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    I realize I didn't make it clear that there wasn't an account set up when the dB was created using phpmyadmin. It was after the dB was created that the customer tried mapping it via the whm > database map tool, and couldn't get anything to work. Neither the dB nor the user ever showed up in the whm sql management tools.

    The plan is to create an actual account and recreate the dB correctly when we can remove the whm/cpanel links to a nonexistent user and dB.

    Side note: We tried removing the following files:

    dBuser.json
    grants_dBuser.cache
    grants_dBuser.yaml

    But that didn't correct the error; we restored those files.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,220
    Likes Received:
    1,376
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you open a support ticket using the link in my signature so we can take a closer look?

    Thank you.
     
  6. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    167
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    Update:
    Somehow, over the weekend, the customer was able to create the desired account. However, cPanel portal wouldn't open and he got an error message.

    We were able to then delete the account, which serendipitously deleted the /var/cpanel/databases files:

    dBuser.json
    grants_dBuser.cache
    grants_dBuser.yaml

    and removed the entry in users.db.

    The only manual editing was in the dbindex.db.json file, where we removed the account:eek:wner entry.

    We then recreated the account, and it was properly created with no errors. We were able to restore the website and the db from backup files the customer had (although there was no .sql dump file).

    Everything works, everybody's happy, customer has links to relevant cpanel doc pages.
     
    cPanelMichael likes this.
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,220
    Likes Received:
    1,376
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm glad to see the issue is now solved. Thank you for sharing the outcome.

    Thank you.
     
Loading...

Share This Page