The midpoint is ((5-2)/2,(4-1)/2)=(3/2,3/2). The slope of the line joining the points is (4-(-1))/(-2-5)=-5/7. So the slope of the perpendicular bisector is 7/5. The equation of the perpendicular is y-3/2=7(x-3/2)/5.
This works out as y=7x/5-21/10+1.5 or y=1.4x-0.6.