Cork came from behind to beat Galway 2-20 to 1-21 in Pearse Stadium on Saturday night.