Pay attention to how you undo the headlight, cuz you will have to reverse the steps to put it back together.
Basically, you have to undo the wiring harness, pull the black rubber grommet thing, undo the black twist on %26quot;cap%26quot; by turning counter-clockwise and there is a wire clip holding the bulb in. Be very careful because the wire does NOT come out. If you break the plastic piece that the wire is attached to, you will need to buy a new headlight. Yike!
Once you are successful in undoing that, take the bulb out and TAKE THE BASE (or socket) OFF! DO NOT THROW AWAY THE BASE. You will have to reuse that. Now reversed all the steps the put it back together.
Here is a link to a headlight diagram for your reference:
http://www.mazdas247.com/forum/attachmen
Be patient and go easy. The first time it took me 45 minute to figure things out. Now I know exactly what to do and it is a little easier. Space is still tight. Make sure you don't touch the new bulb as oil from your fingers will cause the bulb to overheat and burn out faster.