This tutorial covers both types of mining (asteroid and mechanical), and gives detailed instructions on the best method of getting the goods.
Firstly, we'll look at the equipment involved.
The MB4 Mining Machine is the machine that does most of the work. It is left on a planet's surface and extracts material from any veins or deposits it finds and stores the finished products in its hopper.
Once you've landed on the planet's surface, press D to deploy the MB4. You'll see the machine appear in front of your craft, and then it will display a message analysing the surface. First it will check that conditions are suitable for mining (ie. not too hot or cold) then it will analyse the surface and tell you if it has found anything. If it does find something, it will then start mining.
Believe it or not, the MB4 doesn't analyse the same spot on the surface each time it deploys, even though it doesn't seem to move. Therefore it may miss a seam or not find anything at all. For best results, and to make sure that you get the most valuable booty, try deploying the MB4, looking at the analysis and then re-loading it if there's nothing that interests you. Repeat the process until you either find something useful, get bored or decide there's nothing there.
Once you've placed the MB4 to your satisfaction, you may now either take off and return to base or deploy another one. If you do deploy another one, you should make sure that it is at least 1km away from any of your other machines incase you accidentally recall the deployed one and lose the seam.
Having set up your MB4s, and, with any luck, having found rich seams, you'll be wanting to return to the system where your machines are to recover the loot. Hyperspace to the system where you left the machines, and then look at the mining machines info screen (F2, F12). Click on the target button for the machine you want to go to, and it will set your autopilot to that destination. You may, however, prefer to target the planet it is on, since this can be a lot safer...
Land within 1/2 a kilometer of the MB4, and press D. If you're close enough, you'll get a message telling you that the mined material has been loaded. You only need to press once. A second press of D will load the machine itself, which you might not want to do.
Now set off for a system where you can sell the material after you've been to all of your machines.