Soil compaction is one of the crucial factors that restrains the root respiration, energy metabolism and growth of peanut (Arachis hypogaea L.) due to hypoxia, which can be alleviated by ventilation. We therefore carried out a pot experiment with three treatments: no ventilation control (CK), (2) ventilation volumes at 1.2 (T1), and 1.5 (T2) times of the standard ventilation volume (2.02 L/pot). Compared to no-ventilation in compacted soil, ventilation T1 significantly increased total root length, root surface area, root volume and tips at the peanut anthesis stage (62 days after sowing), while T2 showed a negative impact on the above-mentioned root morphological characteristics. At the podding stage (S2, 95 days after sowing), both ventilation treatments improved root morphology, especially under T1. Compared to CK, both ventilation T1 and T2 decreased the activities of enzymes involving the anaerobic respiration, including root lactate dehydrogenase, pyruvate decarboxylase and alcohol dehydrogenase. The activities of antioxidant enzymes of root superoxide dismutase, peroxidase and catalase also decreased at S1, while superoxide dismutase and peroxidase significantly increased under T1 at S2. The ventilation of compacted soil changed soil nitrogen-fixing bacterial communities, with highest bacterial alpha diversity indices under T1. The Pearson correlation analyses indicated a positive relationship between the relative abundance of Bradyrhizobiaceae and root activity, and between unclassified_family of Rhizobiales and the root surface area, while Enterobacteriaceae had a negative impact on the root nodule number. The Pearson correlation test showed that the root surface, tips and activity positively correlated with root superoxide dismutase and peroxidase activities. These results demonstrate that soil ventilation could enhance plant root growth, the diversity and function of soil nitrogen-fixing bacterial communities. The generated results from this present study could serve as important evidence in alleviating soil hypoxia caused by compaction.