Failed To Create The Account | Conflicts With An Unmanage MySQL

Ammar Iftikhar

IT Specialist
Cloud Security Engineer
DevOps Engineer
AWS
Azure
Linux
Just wanted to share a quick solution to a challenge I faced while restoring a cPanel account. After terminating the account from WHM and attempting to restore it using the WHM restore script (/script/restroepkg), I encountered an error that read:
“Failed to create the account: The system could not create the user ‘yourusername’ because it conflicts with an unmanaged MySQL database user.”
“Skipped item (“AccountRestoration::_run_restore_system_module”, line 518): The “Account” restore module failed because of an error: Failed to create the account: A database owner with the name “yourusername” already exists in the database map (/var/cpanel/databases/yourusername.*). at /usr/local/cpanel/Whostmgr/Accounts/Create.pm line 1404.”
Issue Resolution:The error was related to a conflicting MySQL database user, and here’s how I tackled it:
Delete Associated .json File:Navigate to the directory /var/cpanel/databases/.Delete the .json file associated with your username mentioned in the error.
Examine Database Map:Ensure there are no conflicting entries in the database map located at /var/cpanel/databases/map.
Verify Existing Account:Check if the account ‘yourusername’ already exists on the system using the command: /scripts/whoowns yourusername.If it exists, remove it with caution using: /scripts/removeacct yourusername.
Check MySQL User:Run mysql -e “SELECT user, host FROM mysql.user WHERE user = ‘yourusername’;” to identify any existing unmanaged MySQL users with the same name.
Remove MySQL User:If there is a conflicting MySQL user, use mysql -e “DROP USER ‘yourusername’@’localhost’;” to delete it.
Conclusion:Remember, when making system changes, always have backups in place. If you encounter similar issues, these steps might help.
Wishing you smooth server experiences!
Partner With Ammar
View Services

More Projects by Ammar