If you play tabletop role-playing games for long enough, you'll eventually have a character die. It could be that the rule system has character death as a feature, the Dungeon Master is out for blood, or your dice decided to hate you that day. Regardless, as players we still have choices on how to deal with it. I've talked about this topic on the Dungeon Master side so I thought I should be thorough and look at the player side too.
This is really more advice for newer players, but it still stands. Be prepared going into the game that your character could die. As a player, you are there to experience a story through your character. Even if you are there for the dungeon crawling, you will probably come back with at least one story you like to tell people. Part of that experience is having the world, or at least part of it, against you. Risk is part of the game but also part of the fun. It makes those close calls meaningful. However, when death does strike, you have to accept it and get on with the game. Your Dungeon Master might let you come back or be revived or something. Even if your character doesn't come back, there is still a story to experience and you don't want to make things less fun for your fellow players. Your death could very well add something to the experience.
Part of what makes a character death painful is the investment. We put time into coming up with our characters, their mannerisms, their motivations, their actions and everything else we need over the course of the game. However, if you know going into a game that death will be extremely common, you might want to think twice about investing a couple of hours coming up with a backstory. Many of the games I played like that, the Dungeon Master specifically warned us a head of time not to get too attached to our characters and not to bother writing short stories about them. These kinds of expectations often happen. How can you expect your players to spend hours making their backstory if they won't last 30 minutes? If your Dungeon Master makes it hard to die permanently though, don't be too surprised if they also expect you to take more care in your character's background. This might not be the case though, so you might need to ask them point blank (though they might like it if you do, they might not expect it). Instead, you might come up with a large part of it as the game goes along or other things might be more important.
Kind of like the earlier “Be Ready” section, a piece of advice that I think is quite good is to think about your next character a little bit. One of the issues that come up due to character death is that the story can get muddled on the player's side of the screen. If this bothers you, you can tie your next character to either your previous character's history/death or even to another character's (this can be quite fun, though you might want to ask the other player for permission so you don't step on their toes). Since the new characters are related, it ends up building on the story of the previous character.
You don't want to do this every time, though. Sometimes, the campaign could really use that one character death that brings home the costs of what's going on or just some fresh blood. It also can seem way too convenient if characters die very frequently and you use the same technique every time. People only have so many cousins and brothers who want revenge. Think of this idea more like a consideration or a possibility and less like a general piece of advice.
Wanting a Change
Sometimes players plan out their character deaths. It's that classic situation of a player who doesn't like their character anymore and wants a new one. In that case, it's often great all around. There gets to be a character death that makes things seem more dangerous and the player gets a new character. Just like the earlier case, you probably don't want to overuse this. There is the occasional person who likes playing the redshirt and has fun with a character that rarely lasts the whole session. If that's not what you or your Dungeon Master wants though, remember it's not the only option. It could also make player death feel too scripted and odd in a campaign where player death isn't very common, and resurrection magic is a trip to your local abbey away.
All That Starts
Some stories run longer than others. Some characters have stories that are shorter than others. But if you have a story you remember fondly or makes you want to go play D&D or whatever system you like, you are doing it right. Sometimes character deaths are one of them.