Mysql 5.1.X How to upload data from dump file without the partitioning commands

command lineMySQLmysqldump

I need to upload data from a dump file (large one) that includes partitioning info into a database that doesn't support partitioning.

How can I tell the mysql command line to ignore the partitioning information in the dump file?

Notes:
The dump file isn't created by me. Its an auto generated backup so creating it without partitions is not an option.

The file is too large to edit manually. But adding a line to it is an option.

Thanks !

Best Answer

If your target database is an older MySQL version such as MySQL 5.0, then partitioning commands will already be ignored since they are wrapped in comments like this:

/*!50500 PARTITION BY RANGE  COLUMNS(column)
(PARTITION partition_name VALUES LESS THAN ('value') ENGINE = InnoDB,
 PARTITION partition_name VALUES LESS THAN ('value') ENGINE = InnoDB) */;

If you are loading into MySQL 5.1 or higher, then one trick that came to my mind is to change the version number in the comment section. You do not have to manually edit the dump file, you can process the file through sed. For example:

sed 's\!50500 PARTITION\!60000 PARTITION\g' dumpfile.sql | mysql