The multiconfiguration relativistic random-phase approximation(MCRRPA) is applied to the photoionization of magnesium atom. The influence of relativistic and correlation effects on the cross section, angular distribution, and spin polarization parameters of photoelectrons is studied in detail. In the photon-energy region between the first and second ionization thresholds of autoionization due to the doubly-excited states, there are five Rydberg series coupling strongly to each other. The relation of the variations of the angular distribution, and spin polarization parameters in the vicinity of each resonance to the positions and widths of these doubly-excited states are studied.