Now I see the trouble with what you were asking. Does this give you what you're after? It uses a correlated subquery [child] to concatenate the list for each row in [parent]. The [formatted] name is just for formatting it nicely and removing the trailing comma. Since there was no table name in the original post, I used a temporary table named [#test], but you can change it however you like.
SELECT formatted.grade, LEFT(formatted.grade_id_list, LEN(formatted.grade_id_list) - 1)
FROM (SELECT DISTINCT parent.grade, (SELECT CONVERT (Varchar, child.id_grade) + ','
FROM #test child
WHERE child.grade = parent.grade
ORDER BY child.grade
FOR XML PATH ('')) grade_id_list
FROM #test parent) formatted
ORDER BY formatted.grade;
I have no idea if this will work in MySQL at all.