Inspired by the emergence of compounds with novel structures and unique properties (i.e., superconductivity and hardness) under high pressure, we systematically explored a binary Mg-P system under pressure, combining first-principles calculations with structure prediction. Several stoichiometries (Mg P, Mg P, MgP, MgP , and MgP ) were predicted to be stable under pressure. Especially, the P-P bonding patterns are different in the P-rich compounds and the Mg-rich compounds: in the former, the P-P bonding patterns form P , P , quadrilateral units, P-P⋅⋅⋅P chains or disordered "graphene-like" sublattice, while in the latter, the P-P bonding patterns eventually evolve isolated P ions. The analysis of integrated-crystal orbital Hamilton populations reveals that the P-P interactions are mainly responsible for the structural stability. The P-rich compounds with stoichiometries of MgP, MgP and MgP exhibit superconductive behaviors, and these phases show T in the range of 4.3-20 K. Our study provides useful information for understanding the Mg-P binary compounds at high pressure.