Mangrove forests, a critical coastal ecosystem, face numerous anthropogenic threats, particularly from aquaculture activities. Despite the acknowledged significance of viruses in local and global biogeochemical cycles, there is limited knowledge regarding the community structure, genomic diversity, and ecological roles of viruses in mangrove forests ecosystems, especially regarding their responses to aquaculture. In this study, we identified 17,755 viral operational taxonomic units (vOTUs) from nine sediments viromes across three distinct ecological regions of the mangrove forests ecosystem: mangrove, bare flat, and aquaculture regions. Viral assemblages varied among three regions, and the pathogenic viruses associated with marine animals, such as the white spot syndrome virus (WSSV) from Nimaviridae, were identified in this study. The relative abundance of Nimaviridae in the bare flat region was higher than in other regions. Furthermore, viruses in distinct mangrove forests sediments regions have adapted to their environments by adopting distinct survival strategies and encoding various auxiliary metabolic genes involved in carbon metabolism and antibiotic resistance. These adaptations may have profound impacts on biogeochemical cycles. This study provides the first insights into the effects of vegetation cover and aquaculture on the community structure and ecological roles of viruses in mangrove forests sediments. These findings are crucial for understanding the risks posed by anthropogenic threats to mangrove forests ecosystems and informing effective management strategies.