Sometimes, you read a book or story in which one of the main characters is somebody others flock to. Visionary, charismatic, a real champion of a cause, or maybe just really fun to be around. We see it in Atlas Shrugged, with John Galt (well, when we eventually see John Galt). We see it in Stranger in a Strange Land, with Valentine Michael Smith. There is a fine line between a character who is supposed to be a strong, idealistic, individualistic leader, and a total Mary Sue (or Gary Stu, for the male version).
If you're lucky, you've never really read a book with a Mary Sue, but that's probably not true. You might just not know the term. A Mary Sue is, succinctly, a character that's good at everything, with no discernible flaws, typically recognizable as a fantasy of a perfect self that the author is putting forth (Wikipedia article to be found here.)
Another guy that comes to mind, as a non Gary Stu example, is Jay Gatsby of The Great Gatsby. He's handsome, he's rich, he's got a great house, he throws great parties. And he's profoundly lonely. All of those things didn't get him what he wanted, the girl.
A good female example (finally, right?) or a non Mary Sue is Scarlett O'Hara, of Gone With the Wind. She isn't beautiful, states the first sentence, but she is charming. She's also stubborn as hell, given to temper, and a fairly gritty survivalist. A good mix of merits and flaws, really; she sees what she wants and goes for it, and hurts people and gets hurt herself, and tries to make everything fit together properly.
Want a Mary Sue example? The best current (ish) one I've got is Twilight. That Bella Swan; she's apparently really pretty, she's really smart, everybody wants to be her friend, her smell is intoxicating to vampires [or am I overlapping Sookie Stackhouse here? Oy], she's delightfully clumsy (though that SPOILERS goes away after she gets turned into a vampire and is the most perfect baby vampire ever without the madness that every other vampire suffers from SPOILERS).
So how, then, do you know? You typically want your main character to succeed, and be likeable. You typically want your main character to be good at stuff, possibly even a whole bunch of stuff that you're bad at but have fantasized being good at. Well, flaws lend reality. Nail biting, poor money control, smoking, a lack of empathy...these things can round out a character, and make you think of that character more as a person, complete with dings and scratches, even if they do have a wonderful ideal. Those dings and scratches make characters human, and make readers keep reading. Would people have loved Gone With the Wind if it was about Melanie? Likely not. Would The Great Gatsby have been as compelling, without that longing? Definitely not.
Let your characters be imperfect. They'll be all the better for it.