Place the socket wrench over the nut on the negative battery cable and loosen it only until the cable is free to slide off. Do not fully remove the nut. Move the cable as far away from the battery as possible, to prevent it from springing back into place.
Turn the Mazda's headlights on. This will help to more quickly drain power from the computer. Wait 5 minutes, then turn the lights off.
Reconnect the battery cable, securely tightening the nut. Start the engine and check the dash to confirm the light has been reset.
For more you can refer to this site