The invention discloses a method of preparing CAPG (Cationic
alkyl polyglucoside) for a
drilling fluid, and belongs to the technical field of chemical
drilling fluid treating agents in oilfields. The method comprises the following steps: (1), reacting the materials of
epoxy chloropropane, water and a catalyst at the
molar ratio of 1:(12-20):(0.02-0.12) at the temperature of 60-100 DEG C for 3-8 h, so as to obtain a 3-
chlorine-1, 2-
propylene glycol aqueous solution; (2), reacting
alkyl polyglucoside and the 3-
chlorine-1, 2-
propylene glycol aqueous solution at the
molar ratio of 1: (0.5-5) at the temperature of 80-110 DEG C for 0.5-4.0 h, so as to obtain a chlorohydrin polyglucoside
aqueous solution; and (3) neutralizing the chlorohydrin polyglucoside aqueous solution with a neutralizer to an extent that the pH value is 6-9, then adding
tertiary amine, and finally reacting
tertiary amine and chlorohydrin polyglucoside for 3 to 10 h at the temperature of 40-80 DEG C and a normal pressure so as to obtain a CAPG aqueous solution, wherein the
molar ratio of the
tertiary amine to the chlorohydrin polyglucoside is 1: (0.2-1.2). According to the method, the CAPG has an excellent shale inhibition performance, and through the CAPG aqueous solution with the concentration of 1%, the primary
recovery rate of the shale is 95.55 percent, while the secondary
recovery rate is 94.70 percent, and the relative
recovery rate is up to 99.11 percent at the temperature of below 120 DEG C.