PurposeAt present, research on the preparation of corrosion inhibitors using modified pyrimidine derivatives is still blank. The purpose of this study is to synthesize a new cationic mercaptopyrimidine derivative quaternary ammonium salt, known as DTEBTAC, that can be used as a corrosion inhibitor to slow down the metal corrosion problems encountered in oil and gas extraction processes.Design/methodology/approachA new corrosion inhibitor was synthesized by the reaction of anti-Markovnikov addition and nucleophilic substitution. The weight loss method was used to study the corrosion inhibition characteristics of synthetic corrosion inhibitors. Electrochemical and surface topography analyses were used to determine the type of inhibitor and the adsorption state formed on the surface of N80 steel. Molecular dynamics simulations and quantum chemistry calculations were used to investigate the synthetic corrosion inhibitor’s molecular structure and corrosion inhibition mechanisms.FindingsThe results of the weight loss method show that when the dosage of DTEBTAC is 1%, the corrosion rate of N80 steel in hydrochloric acid solution at 90? is 3.3325 g m-2 h-1. Electrochemical and surface morphology analysis show that DTEBTAC can form a protective layer on the surface of N80 steel, and is a hybrid corrosion inhibitor that can inhibit the main anode. Quantum chemical parameter calculation shows that DTEBTAC has a better corrosion inhibition effect than DTP. The molecular dynamics simulation results show that DTEBTAC has stronger binding energy than DTP, and forms a network packing structure through hydrogen bonding, and the adsorption stability is enhanced.Originality/valueA novel cationic mercaptopyrimidine derivative quaternium-ammonium salt corrosion inhibitor was designed and provided. Compared with the prior art, the preparation method of the synthesized mercaptopyrimidine derivative quaternary ammonium salt corrosion inhibitor is simple, and the presence of nitrogen-positive ions, sulfur atoms and nitrogen-rich atoms has an obvious corrosion inhibition effect, which can be used to inhibit metal corrosion during oil and gas field exploitation. It not only expands the application field of new materials but also provides a new idea for the research and development of new corrosion inhibitors.