In MySQL, unfortunately, this task cannot be solved in one request. However, there is a method using an intermediate table. You can do, for example, like this:
CREATE TEMPORARY TABLE temp AS SELECT MIN(id) id FROM table GROUP BY name; UPDATE table SET name = null WHERE id NOT IN (SELECT id FROM temp);
Or using your favorite programming language to fulfill the request
SELECT MIN(id) id FROM table GROUP BY name;
And substitute the result of its execution in UPDATE.
UPD> A small explanation of the request - it selects the ID of records with, so to speak, unique NAME. Therefore, in the future, the query is not updated and NOT IN is used. We are updating records that are not included in this list.