I agree with quite a few of the things people have said here, probably most notably the "free yourself to fail" type of sentiment. Being fearful of anything (failure, discomfort, fatigue) when you're racing is typically not helpful.
A couple of mental strategies that have helped me in the past:
1. I realized that slowing down in a race, particularly the type of slowing that you might experience midway through a 5k, is usually because you're anticipating things getting worse, NOT because you actually need to slow down right that second. I mean, almost none of us reach anywhere near our physical limits in a race, so when we slow down, it's not because we need to, it's because our brain says, hey, this hurts and therefore this level of exertion is not ok. So when I start feeling myself slowing down, I say to myself: "You don't need to slow down yet. You might need to slow down later, but right this second, you don't need to slow down. So keep going." It's a staying in the moment thing, but that idea never really worked for me until I framed it like that in my mind.
2. Races are supposed to hurt. That's the whole point. Sometimes, especially if I haven't raced in a while, my entire goal going into a race is to get to a place of discomfort and then stay there as long as possible. The goal is to find the discomfort and then relax into it. Embrace it like a long lost friend, because that is racing. The races where I'm able to get into that mindset almost always go better than races where I get wrapped up thinking about specific goal times. And I guess I would put emphasis on the RELAX part. When things get tough, we tend to tense up, which is the opposite of helpful. Relax your upper body and press on.
3. Slowing down a little bit doesn't really make you feel better, it just lengthens the amount of time it will take to get you to the finish line.