开发者

Rows between two index entries?

开发者 https://www.devze.com 2022-12-17 09:19 出处:网络
I\'m having problems re-importing a database dump made by mysqldump. I ran mysqldump with the order-by-primary option, and I had it run on a table with a unique key (and no explicit primary key, so it

I'm having problems re-importing a database dump made by mysqldump. I ran mysqldump with the order-by-primary option, and I had it run on a table with a unique key (and no explicit primary key, so it sorted by that unique key). My objective in this case was to re-create the table, making the unique key into the primary key.

This dump took a very long time (around 10 days) and it would be a major pain in the ass to run it again. I tried reimporting the dump (with the appropriate schema changes), but mysql choked midway through. I looked in the dumpfile, at the place where it choked - and it looks like someone inserted a spam email right into the text of the dumpfile.

Fortunately, it looks like the damage was isolated, I'm able to see the key right before the garbage, and right after.

tl;dr: if I just sp开发者_开发百科liced out the garbage, I dont know how many keys will be missing between the one before and the one after - the dump is sorted by that unique key, so it makes life easier in that respect. Does mysql have a way to retrieve all rows between two entries in an index?

The key is a 32-character hex string, stored in a CHAR(32) type column. I'm pretty sure I can't use the < or > operators on strings... so any suggestions?


Sorting the mysqldump on the primary key (or unique key) is what made it take so long. Ten days is pretty unbelievable, though.

Doing a sort like this is useful only when you want to backup a MyISAM table and restore it to an InnoDB table. Is this what you're doing?

MySQL certainly does have a way to dump subsets of a table. Check out the --where option of mysqldump. This should allow you to back up the rows that got corrupted.

And yes, you can use < and > on strings in SQL. You can also use the BETWEEN predicate.


My first question would be, how could a Spam mail make it into your database dump and destroy it?

I am guessing it comes from out of one of your data columns, right? Can you show how this E-Mail and how it managed to disturb your dump's structure?

Maybe it was some sort of header injection that caused the dump to insert line breaks where is shouldn't have, I don't know. Anyway, clearing that up would be first priority in my opinion.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号