Tomato, as a typical greenhouse crop, is commonly first planted as seedlings in a variety of substrates before being transplanted into soil. However, there is rare research on the characteristics of the bacterial community in tomato roots under this planting mode. In this study, tomatoes were planted in pots containing three different cultivation media, including soil and two types of substrates in a greenhouse, followed by a transplanting treatment. After collecting tomato root samples, high-throughput sequencing and bioinformatic analysis were used to compare the differences in bacterial diversity and functions between tomato roots before and after transplanting in different cultivation media. In total, 702776 sequences were obtained, and the OTUs were belonging to 109 genera, 58 families, 41 orders, 14 classes, and 12 phyla. Among the three cultivation media, theβ-diversity was significant, and there was a slight difference in bacterial species diversity along with a large difference in their abundance at the genus level. Soil and both substrates had 79 bacterial genera in common, these genera accounted for 68.70%, 76.70%, and 71.17% of the total genera found in the soil, substrate 1, and substrate 2, respectively. After being transplanted from the two substrates to the soil, the bacterial community structure and abundance exhibited similarities with those found in the soil. Furthermore, based on microbial function prediction, the microbial communities in the two-substrate environment demonstrated a greater potential for promoting growth, while the microbial communities in the soil exhibited a greater tendency to exert their antibacterial potential. Our findings offer theoretical support for the creation of artificially reconstructed microbial communities in greenhouse cultivation.