Background Melatonin can improve mitophagy, thereby ameliorating cognitive deficits in Alzheimer’s disease (AD) patients. Hence, our research focused on the potential value of melatonin-related genes (MRGs) in AD through bioinformatic analysis. Methods First, the key cells in the single-cell dataset GSE138852 were screened out based on the proportion of annotated cells and Fisher’s test between the AD and control groups. The differentially expressed genes (DEGs) in the key cell and GSE5281 datasets were identified, and the MRGs in GSE5281 were selected via weighted gene coexpression network analysis. After intersecting two sets of DEGs and MRGs, we performed Mendelian randomization analysis to identify the MRGs causally related to AD. The biomarkers GSE5281 and GSE48350 were identified through receiver operating characteristic (ROC) curve and expression analyses. Furthermore, gene set enrichment analysis, immune infiltration analysis and correlation analysis with metabolic pathways were conducted, as well as construction of a regulator network and molecular docking. Results According to the Fisher test, oligodendrocytes were regarded as key cells due to their excellent abundance in the GSE138852 dataset, in which there were 281 DEGs between the AD and control groups. After overlapping with 3,490 DEGs and 550 MRGs in GSE5281, four genes were found to be causally related to AD, namely,GPRC5B,METTL7A,NFKBIAandRASSF4. Moreover,GPRC5B,NFKBIAandRASSF4were deemed biomarkers, except forMETTL7A, because of their indistinctive expression between the AD and control groups. Biomarkers might be involved in oxidative phosphorylation, adipogenesis and heme metabolism. Moreover, T helper type 17 cells, natural killer cells and CD56dim natural killer cells were significantly correlated with biomarkers. Transcription factors (GATA2, POU2F2, NFKB1, etc.) can regulate the expression of biomarkers. Finally, we discovered that all biomarkers could bind to melatonin with a strong binding energy. Conclusion Our study identified three novel biomarkers related to melatonin for AD, namely,GPRC5B,NFKBIAandRASSF4, providing a novel approach for the investigation and treatment of AD patients.