Treating migraines can be as tricky as pinning down their causes. To understand and help prevent attacks, try keeping a headache diary to try and find the migraine triggers you want to avoid. Some people may also be prescribed prophylactic, or preventive medications, such as beta-blockers or anti-depressant medications.
Once a migraine strikes, though, writing in a diary probably won't help. To stop an attack in its tracks, you need abortive medication, such as over-the-counter painkillers, or prescription medications such as NSAIDs or triptans.
Whenever you take medication, whether it's an over-the-counter medication, a herbal remedy, or a prescribed medication, your pharmacist is there to help you take them safely. Make sure to ask your pharmacist as many questions as you need to so you really know a medication before you put it in your medicine cabinet.