SOLVED Existing database user can't be found

jndawson

Well-Known Member
Aug 27, 2014
346
38
78
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?
 

jndawson

Well-Known Member
Aug 27, 2014
346
38
78
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
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.
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.
 

jndawson

Well-Known Member
Aug 27, 2014
346
38
78
Western US
cPanel Access Level
DataCenter Provider
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.
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

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

Thank you.
 

jndawson

Well-Known Member
Aug 27, 2014
346
38
78
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.
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

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

Thank you.