2

I will remotely query mysql database and I want to check that the received dataset matches the table in the host computer. How do you do that? I am fairly new to sql database. I know of Checksum and md5, but how do you use them to verify the received dataset is not corrupted on the local machine.

6
  • On Linux or Windows? – Vérace Oct 26 '17 at 19:13
  • On Linux preferably – ThN Oct 27 '17 at 16:18
  • Just to confirm: You're running a query (like, SELECT * from myTable ORDER BY myDate DESC LIMIT 5), for use in some other process (say, a web application - may be these are 5 recent messages this user received), and you want to confirm that the dataset returned matches the dataset the DB engine provided? Or, you've copied data from one table to another, and you want to confirm everything matches (as in @Vérace's answer)? – RDFozz Oct 27 '17 at 18:06
  • @RDFozz That is correct. – ThN Oct 30 '17 at 16:31
  • @ThN - Uh, which of the two options I presented is correct? (it may not matter, at this point - I think Rick James covers the first possibility, and Vérace covers the second) – RDFozz Oct 30 '17 at 16:35
2

Why?

If there is a hardware error in the machine, all sorts of things will be dying, not just your one query.

If you are concerned about the network, see all the checksums, etc, involved in TCP/IP and Ethernet. You don't need a layer of checks on top of that.

If you are asking about consistency between Master and Slave in replication, then say so; that gets into a different area of things.

Bottom line: Don't worry. Resultsets are corrupted about as often as you get hit by a meteorite.

2
  • lol... I guess you are right about the meteorite.. :) Well, I was asked how reliable this sort of setup is recently and if there is away to make sure that we don't ever receive any corrupted dataset. – ThN Oct 30 '17 at 16:32
  • KISS. If I were doing it, I would decide risk of a bug in my 'unnecessary' checksum might be higher than the risk of a well debugged hardware+software corrupting my data. There's always some edge case that I forget to take care of. And when I do, I am unlikely to test it thoroughly enough. – Rick James Oct 30 '17 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.