Immune memory is the ability of organisms to elicit potentiated immune responses at secondary infection. Current studies have revealed that similar to adaptive immunity, innate immunity exhibits memory characteristics (called "innate immune memory"). Although epigenetic reprogramming plays an important role in innate immune memory, the underlying mechanisms have not been elucidated, especially at the individual level. Here, we established experimental systems for detecting innate immune memory in Drosophila melanogaster. Training infection with low-pathogenic bacteria enhanced the survival rate of the flies at subsequent challenge infection with high-pathogenic bacteria. Among low-pathogenic bacteria, Micrococcus luteus (Ml) and Salmonella typhimurium (St) exerted apparent training effects in the fly but exhibited different mechanisms of action. Ml exerted training effects even after its clearance from flies, while live St persisted in the flies for a prolonged duration. RNA sequencing (RNA-Seq) analysis revealed that Ml training enhanced the expression of the immune-related genes under the challenge condition but not under the non-challenge condition. In contrast, St training upregulated the expression of the immune-related genes independent of challenge. These results suggest that training effects with Ml and St are due to memory and persistence of immune responses, respectively. Furthermore, we searched for the gene involved in immune memory, and identified a candidate gene, Ada2b, which encodes a component of the histone modification complex. The Ada2b mutant suppressed Ml training effects on survival and disrupted the expression of some genes under the training + challenge condition. These results suggest that the gene expression regulated by Ada2b may contribute to innate immune memory in Drosophila.