Periodic solution for the magnetohydrodynamic equations with inhomogeneous boundary condition