Infections with multidrug-resistant bacteria that are difficult to treat with commonly used antibiotics have spread globally, raising serious public health concerns. Conventional bacterial detection techniques are time-consuming, which may delay treatment for critically ill patients past the optimal time. There is an urgent need for rapid and sensitive diagnosis and effective treatments for multidrug-resistant pathogenic bacterial infections. Advances in nanotechnology have made it possible to design and build nanomaterials with therapeutic and diagnostic capabilities. Functional nanomaterials that can specifically interact with bacteria offer additional options for the diagnosis and treatment of infections due to their unique physical and chemical properties. Here, we summarize the recent advances related to the preparation of nanomaterials and their applications for the detection and treatment of bacterial infection. We pay particular attention to the toxicity of therapeutic nanoparticles based on both in vitro and in vivo assays. In addition, the major challenges that require further research and future perspectives are briefly discussed.