The invention relates to the field of organic nonlinear optical materials and relates to methyl pyridinium with an organic two-photon absorption material, and a preparation method and the application of the methyl pyridinium. The structural formula of the product is described in structural formula (I); the preparation method comprises the steps of taking 2,6-dimethyl pyridine as a raw material and finally obtaining a compound (I) by conducting oxidizing reaction, esterification reaction, methylolation reaction, halogenation reaction, nucleophilic addition reaction, Wittig reaction and the final methylation reaction. The raw materials are easy to access, and the synthesis steps are simple. The compound (I) has excellent two-photon absorption performance and good water solubility and is an ideal biological fluorescence probe; an obvious solvatochromism phenomenon easily occurs, the compound can be used for detecting water content in a common organic solvent, can also be used as a fluorescent probe for detecting the PH value in a solution system, has a series of advantages of high sensibility, quick response, identification by naked eyes and the like, and has an excellent application prospect.