Magnesium and its alloys have been considered the lightest engineering structural metal materials, but their poor plasticity and the degradation of mechanical properties at high temperatures limit their wide application. Therefore, using molecular dynamics simulation, this work examines how the phase structure and mechanical characteristics of pure magnesium under compressive loading are affected by graphene and varying temperatures. The findings demonstrate that adding graphene can significantly increase magnesium's strength. As well as its Young's modulus, and have a great influence on the secondary strain's strengthening. It is noted that the Gr/Mg-based composites have the same plastic deformation behavior as that of pure magnesium, and both of them undergo a transition from a dense hexagonal structure to other structures during plastic deformation, and the introduction of graphene makes the transition more drastic. The number of embedded graphene layers governs the overall deformation of the Gr/Mg composites; however, it does not significantly affect the deformation behavior of the magnesium matrix in the upper and lower regions of the composites. When there is no graphene embedded, the phase transition of magnesium matrix occurs everywhere, while when graphene is embedded, the phase transition of magnesium matrix in the upper and lower parts of graphene extends along the near-interfacial position of graphene without passing through it, which means graphene has the role of changing the nucleation position of dislocations and blocking the movement of dislocations. In addition, the temperature decreases the phase transition step size of Gr/Mg composites, which is similar to that of pure magnesium, while the temperature affects the phase structure of pure magnesium Gr/Mg composites.