The invention provides an anthraquinone derivative, as well as a preparation method and application of the anthraquinone derivative serving as an antibacterial agent. The preparation method comprises the following steps: culturing a strain of Nigrospora sp. (HM565952) in a strain culture medium; fermenting the nigrospora sp. in a fermentation culture medium; filtering the fermentation broth, removing thallus, and extracting the fermentation broth with ethyl acetate; concentrating the extract, and performing chromatographic separation, and concentrating the eluent to obtain two types of yellow powder, namely 3,5,8-Trihydroxy-7-methoxy-2-methylanthracene-9,10-dione and austrocortirubin; and adding an acetic anhydride reagent in a solution dissolved with the compound, and reacting to obtain the anthraquinone derivative. The anthraquinone derivative obtained from the Nigrospora sp. (HM565952) has selective inhibitory activity to Bacillus subtilis, Bacillus cereus, Micrococcus tetragenus, Micrococcus lutea, Escherichia coli, Staphylococcus aureus, Staphylococcus albus, Vibrio parahaemolyticus and Vibrio anguillarum, and can be used for developing selective bacteriostatic agents; and the raw materials can be produced on a large scale, and not limited by resources. Therefore, the anthraquinone derivative has the advantage of wide application prospect.