Account Creation: Sorry, a mysql user with the name x already exists.

Tags: account restorecPanelmysql user

Published on: August 16, 2014 by George K.

Account Creation:  Sorry, a mysql user with the name x already exists.


A cPanel account restore using the script /scripts/restorepkg immediately after the termination fails with the above message. All traces of the account including the db user are already purged from the server.

Simple Fix:

Wait some more time say 5 minutes and try once again. Most cases it will be resolved


When you delete an account, some parts of the deletion process (which include MySQL drop/revoke/flush stuff) are send to a queue for processing. That is, those processes don’t happen instantaneously along with the WHM interface (or API request). So, when you delete an account, the cPanel database index is queue for updating…but on cPanel account restore it attempts to recreate the account before the index has time to be rebuilt (remember it’s in a process queue), you’ll receive that error. Usually, a simple delay (10-30secs) between deletion and creation preempt this error.

If still fails

1. Check the presence of the user in the MySQL db. For that use the command below.


mysql > use mysql

mysql > delete from user where user='USERNAME';

2. Check the file /etc/dbowners and grep for the username there. If so remove the corresponding entry.

3.  Again grep for the username in /var/cpanel/databases/users.db and if there is a match found, remove it.

4. Finally remove the files /var/cpanel/databases/USERNAME.cache and /var/cpanel/databases/USERNAME.yaml

5.  Once you are done with that, run /usr/local/cpanel/bin/setupdbmap  and make sure that the files are not generated again.

Warning : DON’T execute this on older cPanel servers where the DBs have username_prefix, like in username_dbname


Category : MySQL, Troubleshooting

George K.

George K.

George started his career in web hosting and Linux technical support in the year 2004 and is with SupportSages since 2009. He has keen interest in server optimizations, custom security solutions, hacked server recovery, cyber forensic and high availability fail over system design and implementation. George loves long drives and is passionate about art and literature.

You may also read:


Add new commentSIGN IN

Let's Connect


Your Cart

Cart is empty.

Send this to a friend