To achieve the resource utilization of edible fungi residue and obtain efficient adsorbents for treating dyeing wastewater, biochars were prepared from mushroom residue (MR) with the introduction of alkaline-earth metals (AEMs) and used for methyl orange (MO) wastewater treatment. The thermal behavior of the AEM-treated MR was analyzed using thermogravimetric analysis. The physicochemical properties of the biochars obtained from AEM-treated MR (MRCs) were characterized using Fourier transform infrared spectroscopy, laser particle size analyzer, N2 adsorption/desorption, and scanning electron microscopy. The adsorption performance of MRCs on MO was also investigated. The involvement of AEMs was found to obviously move the main pyrolysis zone of MR to a low temperature region and reduce the temperature corresponding to the maximum weight loss rate and activation energy, which is highly dependent on the concentration of AEMs, the anion and cationic species of the AEMs. Moreover, the addition of AEMs resulted in a decrease in oxygen-containing functional groups (-OH, C–O, or C-O), a weakening of surface negative charges, an enhancement in aromatic functional groups, and an increase in specific surface area of the MRCs. The adsorption performance of MO on MRCs was significantly improved with the introduction of AEMs as well. Among them, MR pre-treated with 5 mmol/g MgCl2 (MR-MgCl25) shows the lowest temperature corresponding to the maximum weight loss rate and the lowest activation energy of 278.52 degrees C and 4.28 kJ/mol, respectively. The biochar prepared from MR-MgCl2-5 under 400 degrees C (MRMgCl2-5-400C) has the weakest surface negative charge and the highest adsorption capacity for MO. The adsorption isotherms, adsorption kinetics, and thermodynamic analysis results showed that the adsorption of MO on MR-MgCl2-5-400C was a spontaneous, chemically dominant monolayer adsorption, with a theoretical maximum adsorption capacity of 81.30 mg/g. This study suggests that AEMs treatment, especially with 5 mmol/ g MgCl2, can readily transform edible fungi residue into a low-cost, high-efficient dyeing wastewater adsorbent.