by having an unpleasant experience or by making mistakes
Oxford100% of films
I learned all that the hard way.
Definitions from the Oxford Advanced Learner's Dictionary, 9th edition