People treat others badly because of their own fears and insecurities. They (usually subconsciously) try to project these fears and insecurities onto someone else in an attempt to feel better.
Once you react to what they have said or done, you take on their pain and make it yours. They feel better for a little while and they can make you believe that the problem is all yours.
When someone is mean to you it can also trigger your own fears and insecurities, so that when you react it means that you not only have taken on their stuff, but your own stuff comes up as well.
So what do you do? First of all, when someone is being mean recognize that they are trying to project their fears onto you. Once you are aware of this you can choose not to take it on. For example, I was on a group committee call once when someone accused me of trying to bully her. In reality, she was the one trying to bully me to make me agree with what she wanted - so I said to her “as a coach I know you are aware that I am not responsible for how you feel and that what you are feeling has nothing to do with me.” I refused to take it on.
When someone feels good about themselves they have no need or desire to be mean to someone else. Understanding this is truly liberating.
Try this affirmation:
“I release the need to allow others to project their fears or insecurities onto me. I claim my power with love.”