I'm a professional bike mechanic. I raced mountain bikes for over 12 years, road for a few years, bmx and track a bit here and there. I did some coaching on the side too.
For riding pain there's a number of things to look at.
Fit is important, you need to have the right top tube length for...