The complex and dynamic population of gut microbiota exerts a marked influence on the host during homeostasis and disease. Imbalance of gut microbiota metabolites may lead to cardiac dysfunction in patients with heart failure, which is related to myocardial infarction(MI) severity. However, the role of gut microbiota in the repair process after MI has rarely been reported. To explore the role of gut microbiota in MI repair and its underlying mechanism, we mixed antibiotics in drinking water to interfere with gut microbiota in rats. Hematoxylin and eosin staining, Sirius red staining, western blotting, and immunohistochemistry were used to detect tissue repair and fibrosis. We found that the expressions of alpha‐smooth muscle actin, collagen, and histone deacetylase (HDAC) activities were significantly increased. We detected gut microbiota at different time points after MI using 16S ribosomal RNA sequencing and detected that Prevotellaceae, Clostridiaceae, and Lachnospiraceae were significantly altered among the butyric acid producers. We administered sodium butyrate via drinking water and discovered that sodium butyrate reduced HDAC activities and adverse repair. Therefore, we speculated that gut microbiota influences the acetylation level and tissue repair process after MI by affecting butyric acid production.