The substituted pentabasic azaheterocyclic compounds of formula I and/or its pharmacological salts and hydrates are provided in the present invention, the groups in the formula are defined as the description. The medicinal composition comprising above-mentioned compounds and/or its pharmacological salts and hydrates is also provided, and the application of said medicinal composition in preparing medicines for preventing or treating the diseases related with AGEs, and in preparing oral preparation for inhibiting or reversing discoloration of teeth, and in preparing antistaling agent of animals and plants protein are disclosed.