Yes magnesium can help with migraines.
If your body is low on magnesium then you can suffer from migraines because of the low levels of magnesium which is known as a magnesium deficiency.
So if you have a magnesium deficiency and you're getting headaches or migraines as a result of the low levels of magnesium then taking some magnesium supplements can help get rid of those migraines and prevent future migraines.
I would go to the doctor and see if you're having a magnesium deficiency as the doctor can do blood tests to test to see if your low on magnesium.
You can buy over the counter magnesium supplements which you can take to improve your magnesium levels but don't take more than needed or required.
Some early signs and symptoms of a magnesium deficiency are, nausea, vomiting, migraines, headaches, fatigue, weakness, vomiting, loss of appetite.