Purpose This investigation aimed to estimate and characterize the microbial diversity in soils with cadmium (Cd) at different concentrations and to evaluate whether Brassica napus can restore the soil microbial diversity. Materials and methods We conducted the pot experiment to analyze the composition of microbial communities in the soil contaminated with 0, 1, and 2 mg/kg Cd, as well as planted with oilseed rape. The bacterial and fungal communities were characterized via next-generation sequencing based on 16S and 18S rRNA gene fragments pyrosequencing, respectively. Results and discussion The results show that cadmium contamination decreased both the microbial richness and diversity in the soil, while the cultivation of oilseed rape increased the richness and diversity. In bacteria, Proteobacteria was the most abundant phylum in all the samples accounting for 39.62 to 46.14%, followed by Bacteroidetes, Actinobacteria, and Chloroflexi. These phyla collectively comprised more than 70% of all phyla. Ascomycota was the most abundant phylum in all samples in fungi (89.65 to 96.00%), and it was the only phylum whose abundance was increased with the rise of Cd concentration. Conclusions Microbial richness and diversity were affected by the combined action of Cd and B. napus. Cd contamination decreased the microbial richness and diversity, while cropping with oilseed rape increased the microbial richness and diversity, which alleviated the deleterious effect of the Cd pollution in soils. These reflected that oilseed rape played a positive role in maintaining species diversity of microorganism from the side.