Undoped and 2, 4 and 6 at.% Mg-doped ZnO nanorods were successfully deposited on ZnO seeded fluorine tin oxide substrates by a simple chemical bath deposition technique to form a photoanode. It was seen that all the samples had a hexagonal wurtzite structure with compact rod morphology. From Tauc's plot results, as compared to the undoped one (3.26 eV), the optical band gap of the ZnO:Mg samples increased to 3.32 eV for 4 at.% Mg-doping concentration and then decreased to 3.27 eV for 6 at.% Mg-doping. Photoluminescence results measured at 300 K indicated that ZnO nanorods had a ultra-violet peak with a wavelength of 382 nm, a blue peak at 420 nm and a deep level band in the range of 450-800 nm. Undoped and Mg-doped ZnO nanorods were subsequently used to realize ZnO-based dye-synthesized solar cells which exhibited the best power conversion efficiency of 0.144 % for 4 at.% ZnO:Mg sample.