Composite fillers are often used to improve the protective properties of coatings. To obtain a high protective performance of epoxy coatings for magnesium alloys, polyaniline (PANI) and graphene oxide (GO) composite powders were selected because of their corrosion inhibition and barrier performance, respectively. The paper mainly focuses on the effect of the preparation methods of the composite powders on the protective performance. PANI and GO composite powders were prepared by in situ polymerization and blending, respectively. First, the composite powder was characterized by X-ray diffractometer, Fourier transform infrared spectroscopy, and scanning electron microscopy. Then, the different composite powders and pure PANI powder were dispersed uniformly in epoxy resin, and the coating was prepared on the surface of the AZ91D magnesium alloy and studied by an electrochemical impedance test, adhesion strength test and physical properties test. The results show that the impedance value of the coating with the added PANI and GO composite powders by in situ polymerization was 4 × 109 Ω·cm2 and higher than that with the added pure PANI (4 × 109 Ω·cm2) and PANI and GO mixed powders (1 × 109 Ω·cm2) after 2400 h immersion in a 3.5% NaCl solution; the former also had better flexibility, ss impact resistance, and adhesion strength. Compared with the direct blending method, the PANI and GO polymerization powders can exert the shielding effect of GO and PANI corrosion inhibition better and achieve a better protective effect on the magnesium alloy.