When the blades of a wind mill move they generate energy. Now, this energy can be used to run a hydraulic pump to lift water from the well.
To grind grains the moving blades of the wind mill with and arrangement of gears can be used to move to very big and heavy stone or metal blocks between which the grains can be ground.