Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have a mysqldump with Indexes. How do I import it by disabling them?

Tags:

database

mysql

I am trying to import a large database but because there's an index, it is taking forever to import the database. I tried copying the raw files to a different machine but for some reason, the largest table is not being read giving me an error: can't read file: 'tablename.MYD. So I mysqldumped my old database but it did so with an index. I cannot do it again because it takes a really long time.

I am trying to import the database but am not sure how to do it without indexes. I thought adding an index after import will be much faster. Does anyone have any suggestions?

like image 433
Legend Avatar asked Dec 30 '25 09:12

Legend


1 Answers

By default, mysqldump produces SQL that disables indexes during mass import and applies them afterward. It looks like this:

/*!40000 ALTER TABLE `my_table` DISABLE KEYS */;
INSERT INTO `my_table` VALUES (...), (...);
/*!40000 ALTER TABLE `my_table` ENABLE KEYS */;
like image 66
John Douthat Avatar answered Jan 01 '26 22:01

John Douthat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!