In performing the detection and tracking of ferromagnetic targets or the detection of magnetic anomalies, a magnetometer array or magnetic gradiometer is often used to suppress interference from environmental background magnetic fields and to improve measurement accuracy. Increasing the distance between the magnetometers is beneficial to improving the signal-to-noise ratio (SNR) of the magnetic gradiometer, but the mismatching error of the magnetometer array affects the accuracy in measuring the magnetic gradient tensor and the positioning accuracy of the ferromagnetic target. In order to calibrate the mismatch error of a magnetometer array, the mounting position and orientation of each magnetometer must be accurately measured. When the magnetometer array is too large, the commonly used calibration methods are difficult to implement because it is difficult to make a rigid support, optical system or robot that is large enough. This paper reports a method that uses two coils and an excitation current source to generate a test magnetic field, after which methods of modulation/demodulation and phase-locked filtering are used to suppress interference from the ambient magnetic field. The output of each magnetometer is recorded, and the particle swarm optimization algorithm is employed to calculate the mounting position and orientation of each magnetometer. After theoretical analysis, computational simulation and experimental verification, the results showed that position measurements over an area of 2.4 m × 2.4 m were accurate to within 0.05 m and the orientation measurements were accurate to within 0.03 rad. The average relative positioning error was less than 1.7%. By designing larger coils and current sources, the needs of larger arrays can be satisfied as long as the same SNR is maintained.