Unicellular bacterial cells exhibit diverse population behaviors (i.e., aggregation, dispersion, directed assembly, biofilm formation, etc.) to facilitate communication and cooperation. Suitable bacterial behaviors are required for efficient nutrient uptake, cell recycling, and stress response for environmental and industrial application of bacterial populations. However, it remains a great challenge to artificially control bacterial behaviors because of complicated genetic and biochemical mechanisms. In this study, we designed facile mesoporous silica nanoparticle (MSN)-based assemblies to intelligently regulate bacterial behaviors with the help of light and magnetic field. This system was composed of magnetic MSNs, i.e., MnFe 2 O 4 @CoFe 2 O 4 @MSN modified by photoactive spiropyran (SP), and the chitosan-based polymers ChiPSP, i.e., chitosan grafted by triphenylphosphine and SP. The assembly strongly bound bacterial cells, inducing reversible bacterial aggregation by visible-light irradiation and dark. Moreover, the formed bacterial aggregates could be further governed by a directed magnetic field (DMF) to form microfibers and by an alternating magnetic field (AMF) to form biofilms. This study realized stimulus-triggered regulation of bacterial behaviors by MSNs and implied the great power of chemical strategies in intelligent control of diverse biological processes for environmental and industrial applications.