When attempting to copy or replicate a mySQL database you recieve the error ‘Copy SQL database user exists’
When copying the SQL database, if the user no longer exists but is still attached to the database security groups, an error will occur when attempting to copy the database and its files.
There are two ways to solve this issue, the first way simply deletes the user account causing the error, the second way will keep the user account during the copy.
- Lauch mySQL manager and run the following SQL query:
- Exec sp_dropuser ‘usercausingerror’
- Re-run the database copy command and the error will no longer occur
- Launch mySQL manager and run the following SQL query:
- The query will list all ‘estranged’ users in the report in the results box, each of the users listed will have to either be dropped or linked to a new account
- To link the user to an account enter the following SQL query:
- The above syntax will link the user account entered to a new non-deleted user account that can then be copied, just run the database copy command again.
Exec sp_change_users_login ‘Auto_Fix, ‘usercausingerror’, NULL, ‘passwordhere’