Use update ignore ...
statement instead of simple update ...
, just be aware of the side effects (last sentence of the quote below). As mysql manual on update syntax says:
With the IGNORE modifier, the update statement does not abort even if errors occur during the update. Rows for which duplicate-key conflicts occur on a unique key value are not updated. Rows updated to values that would cause data conversion errors are updated to the closest valid values instead.
If the side effects are not acceptable to you, then you need to check for duplicate values before updating with a select ... for update
statement to lock the record to be updated. A third alternative would be to ignore duplicate key errors in your application's error handling of this statement. I would go with the last solution, to be honest.