We aimed to determine the relationship between the use of analgesics prescribed for pain management and the onset and progression of mood disorders using a large-scale cohort database. We calculated hazard ratios (HR) with 95% confidence intervals (CI) for patient risk of developing mood disorders based on age, income, health-related variables, disease history, Charlson comorbidity index, and analgesics prescription behavior (Models 1-3). Additionally, we determined the risk of mood disorder occurrence by age group (Model 4) using a proportional hazards regression model. The age- and income-adjusted HR (Model 1) was 1.8275. The age-, income-, BMI-, and physical-activity-adjusted HR (Model 2) was 1.882. The fully adjusted HR (Model 3) was 1.698. Compared with no analgesic use, nonregular use (HR = 1.386) and regular use (HR = 1.698) was associated with a higher risk of mood disorders. Among patients older than 50 years, those who participated in physical activity (less than five days) had a lower risk of mood disorders than those who did not. This suggests that it may be useful for preventing mood disorders in older cancer survivors. A high risk of comorbidities and regular use of analgesics are risk factors for developing mood disorders. Therefore, our results suggest that cancer survivors with a high risk of comorbidities and a history of regular analgesic use should undergo careful psychiatric consultation.