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.