learn (one's) lesson
To learn through painful experience not to do something, often something one had been warned about or knew might be risky. I told you that you'd feel awful if you drank that much wine. I hope you've learned your lesson. I certainly learned my lesson about buying something from a stranger online.
learn one's lesson
Profit from experience, especially an unhappy one. For example, From now on she'd read the instructions first; she'd learned her lesson. Also see hard way.
learn your ˈlesson
learn what to do or what not to do in the future because you have had a bad experience in the past: I used to carry a lot of money on me, until one day my bag was stolen. Since then, I’ve learned my lesson.