The comprehensive utilization of low-grade diatomite resources and the effective treatment of printing and dyeing wastewater have attracted widespread attention. The combined scrubbing-magnetic separation-acid leaching-roasting process was used to increase the SiO2 content from 59.22% to 86.93%, reduce the Al2O3 content from 18.32% to 6.75%, and reduce the Fe2O3 content from 6.85% to 1.24% in the low-grade diatomite from Heilongjiang, China. The TiO2/g-C3N4/diatomite nanocomposite was prepared by a facile ultrasonic-thermal polymerization method. In this ternary structure, diatomite skeleton effectively increased the surface area with abundant adsorption sites, prevented g-C3N4 from restacking, and facilitated the separation of electrons and holes via the formation of TiO2/g-C3N4 heterojunctions. The degradation rate was 98.77%, 90.59%, and 89.16% for the three catalytic reaction cycles of the MB solution, respectively. The composite showed a high degradation rate of the MB solution after three cycles, which indicated that the composite had good recyclability. Through the free radical capture test, it was elucidated that O2−·, h+, and ·OH all played a role in the photocatalytic reaction of the TiO2/g-C3N4/diatomite to the MB solution, in which O2−· was mainly responsible for the photocatalytic oxidation mechanism, and the reaction kinetics were further investigated. This nanostructured TiO2/g-C3N4/diatomite composite has fascinating visible light catalytic activity and excellent stability.