The invention relates to a fiber grating sensor, in particular to a fiber grating liquid flow sensor with temperature compensation or for eliminating the influence of temperature change on a measurement value. The sensor has high data acquisition precision and long service life, can work under the environment of high temperature (over 300 DEG C) and high pressure (over 40MPa) and acquire effective data, and is not affected by the adverse conditions of electric field, magnetic field, explosiveness, flammability and the like; the service life of the sensor is nearly semi-permanent; and the sensor has small volume, is easy to install, has high measurement precision, and can adapt to flow measurement of complex, layered and mixed layers. Particularly in the petroleum extraction process, the requirement of measurement of liquid yield is more prominent; and particularly, the sensor can be applied in the places where the temperature sensors of other forms are not competent, and particularly has great application prospect in the fields of nuclear power plants, oil fields, spaceflight, chemical industry, mining industry, energy conservation, emission reduction and the like.