The invention relates to a method for producing a microbial oil by fermenting corn stalk hydrolysate. The method comprises the following steps: (1) hydrolyzing corn stalks with acid to obtain the corn stalk hydrolysate; (2) adding Ca(OH)2 into the hydrolysate, regulating the pH to 10 to 11, centrifuging the solution for 10 to 20 min at a speed of 3,800 r / min, taking the supernatant, regulating the pH back to 6.0 with phosphoric acid, centrifuging the solution for 10 to 20 min at a speed of 3,800 r / min, taking the supernatant, sterilizing and filtering the supernatant, and regulating the pH of the obtained filtrate with NaOH to 6.0; (3)fermenting and cultivating oleaginous microorganism; and (4)crushing and extracting the dried bacteria in step (3) to obtain the microbial oil. According to the method for producing the microbial oil, the corn stalks are hydrolyzed by dilute sulphuric acid to obtain lignocellulosic hydrolysate, which is detoxified by Ca(OH)2 to effectively reduce or inhibit the fermentation inhibitor in the hydrolysate, so as to promote the fermentation of the microorganism and obtain a large amount of microbial oils which can be further transformed into biodiesel.