The invention discloses a method for recovering a whole MySQL database. The method is characterized by comprising the following steps that S100, a MySQL database file is carved, wherein a magnetic disk is scanned, file features are searched for, a table data file and a table structure file with the file features are obtained, the files are reconstructed according to the serial number of a data page and a table space identifier, and a table definition file is saved; S200, the database file is correlated, wherein the carved MySQL database file and the engine type of the MySQL database are matched, and the table structure file is correlated with the corresponding table data file; S300, a table structure is recovered, wherein whether the table data file is correlated with the corresponding table structure file or not is judged, if yes, S400 is executed, and otherwise, the table structure is recovered according to the engine type; S400, the database file is recovered.