A method for the determination of seven mycotoxins in rice and wheat by ultra performance liquid chromatography-quadrupole-time of flight mass spectrometry (UPLC-Q-TOF/MS) based on self-built database was established. Samples were extracted with 0.2% formic acid aqueous solution-acetonitrile (50∶50, v/v), dehydrated and salted according to the QuEChERS method (4 g of magnesium sulfate, 1 g of sodium chloride, 1 g of sodium citrate, 0.5 g of citrate disodium salt), and separated on an HSS T3 column (100 mm×2.1 mm, 1.8 μm). UPLC-Q-TOF/MS with MSE screening was performed, and the positive and negative ions of the screened mycotoxins were calibrated and quantified using matrix-matched standard curves with time of flight multiple reaction monitoring (TOF-MRM). The results showed that aflatoxin G1 (AFG1), aflatoxin G2 (AFG2), aflatoxin B1 (AFB1), aflatoxin B2 (AFB2), and ochratoxin A (OTA) exhibited moderate matrix effects in rice, while OTA and zearalenone (ZEN) exhibited moderate matrix effects in wheat. The seven mycotoxins showed good linearities in their respective concentration ranges, with correlation coefficients (r) of 0.9900-0.9998. The limits of detection (LODs) for rice and wheat were 0.50-400 and 0.50-200 μg/kg, respectively, and the limits of quantification (LOQs) for both cereals were 1.00-800 μg/kg. In rice, the average recoveries at three spiked levels of low, medium, and high were 88.1%-123.9%, with relative standard deviations (RSDs) of 0.2%-13.6%. In wheat, the average recoveries at three spiked levels of low, medium, and high were 102.0%-123.4%, with RSDs of 0.8%-14.8%. As a result, one batch of 46 batches of rice was screened out for AFB1 and AFB2, with a screening rate of 2.2%, of which the measured values were 10.8 μg/kg and 1.2 μg/kg, respectively. According to GB 2761-2017, the maximum allowable level of AFB1 in rice is 10 μg/kg; thus, the exceeding rate for AFB1 is 2.2%. Deoxynivalenol (DON) was screened out in 9 out of 24 batches of wheat (screening rate, 37.5%), while ZEN was screened out in 19 batches (screening rate, 79.2%). According to GB 2761-2017, the maximum allowable levels of DON and ZEN in wheat are 1000 and 60 μg/kg, respectively. The levels of DON and ZEN detected in the wheat samples did not exceed these limits. The proposed method uses MSE for qualitative screening to avoid the occurrence of false positives caused by interfering compounds with mass numbers and retention times similar to those of the analytes. TOF-MRM mode is then used to quantify the positively screened mycotoxins. The method is fast, accurate, sensitive, and suitable for the isolation and quantitative detection of mycotoxin residues in rice and wheat samples. The findings provide powerful technical support for mycotoxin contamination monitoring in rice and wheat and early risk-warning efforts.