This is me all over. Rather than quote everyone, here's the things that sometimes help me...
1) Reasonable expectations. Showing up at a tourney expecting, even sub-consciously, to throw darts all day is setting yourself up for failure. Even Climo has a "wtf was that?" shot once or twice a year.
2) Humor. This one is hard, but if you can find the humor in the bad shot(s), that can sometimes help relieve both your tension and the guys on your card.
3) Look at a bad shot as a "dare to be great" opportunity. When I shank a tee shot, I try to make my first thought "it's a man-par opportunity."
These are basically already suggested earlier in the thread. I'd add:
4) Post bad-shot shot selection. When I get frustrated, it translates directly to tightening up physically, which is what turns a bogey into a triple, or one 5 into a 5,8,6 on consecutive holes. A lot of recovering from bad shots is damage control. I almost never can make myself do this, but when i get there, the best thing i can do is disc down, slow down, and try to get the next few shots in the fairway, etc. The tendency can be to try to recover from a bad shot by biting off more than you can chew on the next shot(s), hole(s), which for me leads to the mental game death spiral.
Honestly, the best thing that happened to my mental game was, about a year-18 months into playing, I spent the winter practicing for like 2 hours plus 4-5 times a week, field work, not rounds, and focused practice, like 150 foot putter shots over and over, etc. Getting to the point where, when I made a mistake, I could IDENTIFY/DIAGNOSE what I did wrong, really helped to keep the frustration in check.