Objective On the basis of electronic medical records, the data mining technology was adopted to explore the law of chronic kidney disease (CKD) and the intervention mode of mental health of patients. Methods Based on the electronic medical records, the corresponding data extraction, database establishment, and data cleaning of CKD were performed. After that, the related data analysis, frequency analysis, cluster analysis, and nonparametric analysis were used to explore the laws of CKD diagnosis and treatment and nursing intervention mode of mental illness. The most common causes of CKD were chronic glomerulonephritis (43.76%), aristolochic acid nephritis (16.34%), diabetic nephritis (12.87%), and hypertensive nephritis (11.58%). The major treatment method for end-stage patients was alternative therapies, accounting for 46%. Compared with the depression score before intervention, that of the patients after the mindfulness therapy (50.99 ± 9.77 vs. 47.01 ± 9.33, P=0.024 < 0.5) and target behaviour nursing intervention (52.21 ± 8.12 vs. 48.01 ± 9.33, P=0.032 < 0.05) was obviously decreased. Conclusion The data mining technology based on electronic records showed a good application prospect in the analysis of the diagnosis and treatment of CKD; and target behaviour nursing and mindfulness intervention were effective psychological intervention models.