Sometimes we get this error on creating table in MySQL.This error will come when we use the constraint with the same name that is already used somewhere else.
If the table you're trying to create includes a foreign key constraint, and you've provided a name for that constraint, then remember that it must be unique within the whole database. Run the below query to see if that name is in use somewhere in the database:
constraint_type = 'FOREIGN KEY'
AND table_schema = DATABASE()