Mesoporous titanium nanoparticles (MTN) have always been a concern and are considered to have great potential for overcoming antibiotic-resistant bacteria. In our study, MTN modified with functionalized UV-responsive ethylene imine polymer (PEI) was synthesized. The characterization of all products was performed by different analyses, including SEM, TEM, FT-IR, TGA, XRD, XPS, and N2 adsorption-desorption isotherms. The typical antibacterial drug berberine hydrochloride (BH) was encapsulated in MTN-PEI. The process exhibited a high drug loading capacity (22.71 ± 1.12%) and encapsulation rate (46.56 ± 0.52%) due to its high specific surface area of 238.43 m2/g. Moreover, UV-controlled drug release was achieved by utilizing the photocatalytic performance of MTN. The antibacterial effect of BH@MTN-PEI was investigated, which showed that it could be controlled to release BH and achieve a corresponding antibacterial effect by UV illumination for different lengths of time, with bacterial lethality reaching 37.76% after only 8 min of irradiation. The minimum inhibitory concentration (MIC) and minimum bactericidal concentration (MBC) of the nanoparticles have also been studied. The MIC of BH@MTN-PEI was confirmed as 1 mg/mL against Escherichia coli (E. coli), at which the growth of bacteria was completely inhibited during 24 h and the concentration of 5 mg/mL for BH@MTN-PEI was regarded as MBC against E. coli. Although this proof-of-concept study is far from a real-life application, it provides a possible route to the discovery and application of antimicrobial drugs.