The ongoing pandemic of coronavirus disease 2019 (COVID-19) caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) urgently needs an effective cure. 3CL protease (3CL(pro)) is a highly conserved cysteine proteinase that is indispensable for coronavirus replication, providing an attractive target for developing broad-spectrum antiviral drugs. Here we describe the discovery of myricetin, a flavonoid found in many food sources, as a non-peptidomimetic and covalent inhibitor of the SARS-CoV-2 3CL(pro). Crystal structures of the protease bound with myricetin and its derivatives unexpectedly revealed that the pyrogallol group worked as an electrophile to covalently modify the catalytic cysteine. Kinetic and selectivity characterization together with theoretical calculations comprehensively illustrated the covalent binding mechanism of myricetin with the protease and demonstrated that the pyrogallol can serve as an electrophile warhead. Structure-based optimization of myricetin led to the discovery of derivatives with good antiviral activity and the potential of oral administration. These results provide detailed mechanistic insights into the covalent mode of action by pyrogallol-containing natural products and a template for design of non-peptidomimetic covalent inhibitors against 3CL(pro)s, highlighting the potential of pyrogallol as an alternative warhead in design of targeted covalent ligands.