Database Owner Already Exists?

whipworks

Well-Known Member
Aug 19, 2014
165
7
68
cPanel Access Level
Reseller Owner
Hi Support,

Trying to move an account from an old server to a new one. Keeps on failing with error

Account “username”: Account Restore Failed: “Account failure: Failed to create the account: A database owner with the name “username” already exists in the database map (/var/cpanel/databases/username.*). at /usr/local/cpanel/Whostmgr/Accounts/Create.pm line 1225. ”

The account isn't found on the List Accounts. Although we did found the database with the said username which is kinda weird. We tried renaming and even removing it, but the server still gives us the same issue. Is there any procedure on how to completely remove or reset this? Thanks
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,259
313
Houston
@whipworks

The following is an internal tool we use to find account cruft. Could you run this and see if anything comes up for the username?

Code:
/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo) $USER

I'd expect to see all "NOT FOUND" for an account that doesn't exist on the server.
 

mathx

Active Member
Jan 16, 2017
26
3
3
Toronto
cPanel Access Level
DataCenter Provider
tech dude here: Little scary to run a script inline from the web, but downloaded it, looks legit (...i think...) ran it with --cruft:

obviously shows some spurious cruft - how to safely remove?

#./acctinfo --cruft username
<c>
acctinfo - Version: 2.5.15
==============================================================================================
CRUFT CHECK
==============================================================================================
From your query of username I have determined:
userdomain.com (username) was terminated on Tue Apr 30 12:17:04 2019
----------------------------------------------------------------------------------------------
Searching the following files for user: username
/etc/passwd [MISSING]
/etc/group [MISSING]
/etc/shadow [MISSING]
/etc/gshadow [MISSING]
/etc/quota.conf [MISSING]
/etc/dbowners [MISSING]
/etc/trueuserowners [MISSING]
/var/cpanel/databases/users.db is either empty or missing [SKIPPING]
/etc/userdatadomains.json [EXISTS]
/var/cpanel/quotawarned [MISSING]
/etc/nocgiusers [MISSING]
/etc/userips [MISSING]
/etc/userbwlimits [MISSING]
Searching the following files for domain: userdomain.com
/etc/userdomains [EXISTS]
/etc/trueuserdomains [EXISTS]
/etc/userdatadomains [EXISTS]
/etc/domainusers [EXISTS]
/etc/localdomains [EXISTS]
/etc/remotedomains [MISSING]
/etc/demousers is either empty or missing [SKIPPING]
/etc/email_send_limits [EXISTS]
/etc/demoids is either empty or missing [SKIPPING]
/etc/demodomains is either empty or missing [SKIPPING]
/etc/ssldomains is either empty or missing [SKIPPING]
/home/username [MISSING]
Checking other possible home directory locations...
/home1/username [MISSING]
/home2/username [MISSING]
/home3/username [MISSING]
/home4/username [MISSING]
/home5/username [MISSING]
/home6/username [MISSING]
/home7/username [MISSING]
/home8/username [MISSING]
/home9/username [MISSING]
/var/cpanel/userdata/username [EXISTS]
\_ /var/cpanel/userdata/username/main
\_ /var/cpanel/userdata/username/wholesaledsl.userdomain.com
/var/cpanel/users/username [EXISTS]
\_ [WARN]: One or more DNS lines may be missing from this file!
/var/cpanel/databases/grants_username.yaml [MISSING]
/var/cpanel/databases/username.json [MISSING]
/var/cpanel/databases/dbindex.db.json [MISSING]
/etc/proftpd/username [MISSING]
/var/cpanel/bandwidth/username.sqlite [MISSING]
/var/cpanel/bwlimited/username [MISSING]
/var/cpanel/bwlimited/userdomain.com [MISSING]
/etc/valiases/userdomain.com [MISSING]
/etc/vfilters/userdomain.com [MISSING]
/etc/vdomainaliases/userdomain.com [MISSING]
/var/named/userdomain.com.db [MISSING]
/etc/apache2/logs/domlogs/userdomain.com [MISSING]
/etc/named.conf [MISSING]
/etc/apache2/conf/httpd.conf [EXISTS]
Checking for any MySQL users in mysql.user table
\_ username_bookmar
\_ username_faq
\_ username_switcha
\_ username_wp1
\_ username_wp2
\_ username_wp3
\_ username_wpusr
\_ username
Checking for any MySQL users and databases in mysql.db table
\_ username_switcha username\\_userdomain
\_ username_wp2 username\\_wp1
\_ username_wp3 username\\_wp2
\_ username cptmpdb\\_username\\_i76lfu4o0C6GMTnX
\_ username username\\_wp1
\_ username username\\_userdomain
\_ username username\\_admin\\_faq
\_ username username\\_wp2
\_ username username\\_admin\\_bookmarks
==============================================================================================
</c>
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,259
313
Houston
tech dude here: Little scary to run a script inline from the web, but downloaded it, looks legit (...i think...) ran it with --cruft:
Understood, though I can assure you that this has been tested and is something we wrote and use internally, though it is entirely up to you to run it, the full source as you can see is in github and readily available.


For the cruft information - It looks like there's a few spots it didn't get removed cleanly:


These two can be removed:

Code:
\_ /var/cpanel/userdata/username/main
\_ /var/cpanel/userdata/username/wholesaledsl.userdomain.com
Once you remove them you'd want to run the following:

Code:
/scripts/updateuserdomains
/scripts/updateuserdatacache
Once that's complete you would want to rebuild the apache configuration so that the entry is no longer present:

First make a copy:
Code:
mv /etc/apache2/conf/httpd.conf{,.bk}
then rebuild/restart:
Code:
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd
For the users:
Code:
Checking for any MySQL users in mysql.user table
\_ username_bookmar
\_ username_faq
\_ username_switcha
\_ username_wp1
\_ username_wp2
\_ username_wp3
\_ username_wpusr
\_ username
If you go to WHM>>SQL Services>>Manage Database Users do the above users show up and if so are you able to edit them to modify the name to no longer include the user? If not you'd manually need to remove the user from MySQL

Something like the following may be useful (using the first name in the list as an example):

Code:
DROP USER 'username_bookmar'@'localhost';



Thanks!
 

mathx

Active Member
Jan 16, 2017
26
3
3
Toronto
cPanel Access Level
DataCenter Provider
ok done all that, deleted mysql users, reran acctinfo.

issue is there's a separate user for two other related accounts (this is for the hosting company itself) 'accounts.userdomain.com' and 'secure.userdomain.com'
so I think acctinfo is triggering that some of this still exists:

probably should be a grep -w $username and $userdomain on these files, not a plain grep which will match domains that contain the same characters:

(grep -wlr username /etc/*domain* returns nil, whereas grep -lr username /etc/*domain* returns lots)

CRUFT CHECK
==============================================================================================
/etc/userdatadomains.json [EXISTS]

Searching the following files for domain: userdomain.com
/etc/userdomains [EXISTS]
/etc/trueuserdomains [EXISTS]
/etc/userdatadomains [EXISTS]
/etc/domainusers [EXISTS]
/etc/localdomains [EXISTS]
/etc/email_send_limits [EXISTS]
/var/cpanel/userdata/username [EXISTS]
/var/cpanel/users/username [EXISTS]
/etc/apache2/conf/httpd.conf [EXISTS]


but

/var/cpanel/userdata/username [EXISTS]
/var/cpanel/users/username [EXISTS]

is definitely correct. Should I delete those last 2?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,259
313
Houston
I'm sorry, I missed that second one initially there, yes they should definitely be removed. Then run the same script:




Code:
\_ /var/cpanel/userdata/username/main
\_ /var/cpanel/userdata/username/wholesaledsl.userdomain.com
Once you remove them you'd want to run the following:

Code:
/scripts/updateuserdomains
/scripts/updateuserdatacache
Once that's complete you would want to rebuild the apache configuration so that the entry is no longer present:

First make a copy:

Code:
mv /etc/apache2/conf/httpd.conf{,.bk}
then rebuild/restart:

Code:
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd
 
  • Like
Reactions: mathx

whipworks

Well-Known Member
Aug 19, 2014
165
7
68
cPanel Access Level
Reseller Owner
Can we open a ticket to have this fixed please? Seems that all the scripts above isn't doing anything. We were trying to recover another account on the same server and it's showing the same issue. It's saying the account already exist.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,259
313
Houston
Can we open a ticket to have this fixed please? Seems that all the scripts above isn't doing anything. We were trying to recover another account on the same server and it's showing the same issue. It's saying the account already exist.
Hi @whipworks

You're always more than welcome to open a ticket with us. We'd be happy to assist you with this issue.