Photoelectrical dynamic in the solar cells is strictly controlled by the electron trap that originated from the lattice defects and the interfacial charge transfer. Here, we report that the Mg doping on the anatase TiO2 photoanode can passivate the electron trap that boosts up both the interfacial charge transfer and transport dynamics, enhancing the photovoltaic performance of the DSSC device. We found that the power conversion efficiency improve by up to more than 58%, i.e. from its original condition of 2.96% to 4.68%, when the TiO2 was doped with the Mg. Our result indicated that the Mg doping improved the Voc, FF, and reduce the leakage current, the processes that verify the enhancement of the dynamic of the photogenerated carrier in the device. The effective electronic trap passivation is assumed driven by the highly reactive Mg metal that actively donates electron to the anion vacancy of TiO2. The Mg doping should be the potential platform for the enhancement of carrier dynamic in the solar cells device.