You can mine your own life, yes. But you can also sympathetically observe other people’s experiences. You can read and research. And you can use your imagination. What good writers know about their subjects is usually drawn from some combination of these sources.
Just because you have never been to outer space does not mean you cannot write about an astronaut--or an alien. Still, for a writer just starting out, the injunction to "write what you know" does seem to mean "mining your own life," and that can just about shut you down. It almost did me.
At least from an external point of view, and frequently enough from my own, my life seemed to be pretty boring. Writing about a girl or a woman who grows up in the suburbs, gets good grades, plays the flute, almost becomes a bowling champion but soon becomes too embarrassed to continue with this particular endeavor, goes to college, goes to grad school ... well, I, for one, couldn't find a hell of a lot of material in these events as events. (I did write a bowling story, though.)
But, as Mohsin Hamid explains:
It may be that the DNA of fiction is, like our own DNA, a double helix, a two-stranded beast. One strand is born of what writers have experienced. The other is born of what writers wish to experience, of the impulse to write in order to know.
I have similarly learned that it's the interaction of known and unknown experiences that makes characters and events believable. Like Hamid, I think some element of not knowing is central to creating a successful story. The act of stretching to make something you don't know into something you do forces you to consider viewpoints, details, and sensations you might otherwise overlook.
So, for example, I could put a nervous, overthinking type like myself into a situation I've never actually been in--say, on a moon colony. Now, I'll have to do some research to make that moon colony plausible, though I don't feel I have to understand every element of the ventilation system and what have you. What's more important is how someone like me would inhabit a place like that. Would I become obsessed with ventilation, and air, and is there air? what is air? why can't I see it? am I going to die in the next two seconds? I imagine so.
Or flip the terms: how would a person completely unlike me--or a talking dog or a lobster from Titan--live the life I've led thus far? Would the dog ignore taunts about bowling as a working-class non-sport and proudly lead his team to the Ohio state championship? How would the lobster handle literary event-planning? (Better than I did--that's one thing I know for sure.)