Mg x Ga2O4 epitaxial films with different Mg component ratios (x = 0.6, 0.8, 1, 1.1, and 1.4) and their metal-semiconductor-metal solar-blind ultraviolet (SBUV) photodetectors are prepared on c-face sapphire by metal-organic chemical vapor deposition (MOCVD). The structure, composition, crystalline quality, and optical properties of the Mg x Ga2O4 thin films have been investigated in detail. It can be found that five Mg x Ga2O4 thin films have the spinel structure with a similar bandgap of approximate to 5.15 eV, and the highest crystalline quality is observed in Mg x Ga2O4 with x = 1. Besides, photodetector based on Mg x Ga2O4 film with x = 1 has the highest responsivity, the largest UV-visible rejection ratio, and the fastest response speed. As the content of Mg deviates from the stoichiometric ratio of MgGa2O4, the crystalline quality of the Mg x Ga2O4 thin film is reduced, and their photoelectric response characteristics are deteriorated. This work indicates that MgGa2O4 is a promising candidate for the applications in high-performance solar-blind ultraviolet photodetectors.