Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to install the mysql patch available here...

I have the mysql version 5.5.20 

but I do not know how to copy the code. I am using centOS. I tried to search Google but did not find any tutorial that will explain how to patch mysql code.


I tried to download the file and add the code to current mysql codebase as follows:

# wget

# patch --dry-run < myp.patch
patch: **** Only garbage was found in the patch input.

I am getting an error mentioned above.

Update 1:

When I add the path to the original file, I get the following error:

# patch --dry-run /usr/sbin/mysqldump  < /root/download/myp.patch
patching file /usr/sbin/mysqldump
Hunk #1 FAILED at 99.
Hunk #4 FAILED at 2348.
Hunk #7 FAILED at 3209.
3 out of 11 hunks FAILED -- saving rejects to file /usr/sbin/mysqldump.rej
share|improve this question
If you don't know how to apply the patch I suggest you stick to using the normal release version, either the outdated ones available from the CentOS repos or building from the latest from source code. If you still intend to apply the patch ensure you have the version of MySQL listed (5.5.20). – John Gardeniers Feb 8 '12 at 3:41
Are you trying to patch the binary instead of mysqldump.c in the source code? – jkj Feb 8 '12 at 6:51
up vote 3 down vote accepted

As jkj says in the comment above, the problem is that you appear to be trying to patch a binary. I apologise for simply repeating his/her comment, but I decided that if it was right, merely upvoting it wasn't emphatic enough, because what you're doing will never work.

That's not how patches function. Patches are text changes that are applied to an existing piece of text, in this case the source for mysqldump, so that the binary can be rebuilt as part of the normal build.

You don't say how you got the version of mysql you're running, but assuming that it's from a package rather than from source - as would be normal on CentOS - you've got an awful lot of work to do. First, you'll need to build mysql from source, and replace the existing packaged version (or, for much less pain, build it to install alongside in a custom directory). Then you'll have to verify that the newly-built mysql does what you expect. Then you'll have to patch the sources, and rebuild the binaries.

The reason for the verification step above is because of Red Hat's patching policy, which is that they will often include fixes for both the version of something they provide, and indeed they will backport useful fixes from later versions, without bumping the version number. The corollary of this is that you can't be sure that RH's mysql 5.5.20 is anything like MySQL's 5.5.20.

Indeed, you might do better to get the mysql SRPM (RPM of sources) from redhat, install that, and check by eye to see if the patch you want is already included. Even if it's not, the SRPM will give you a much closer approximation to the correct sources to reproduce the binaries you have installed. The downside is that if RH have made any other changes to mysqldump.c, the patch will no longer apply cleanly, and you will need some knowledge of the code to get it to do so without wildly breaking things.

If this is all known to you, I apologise for laying it out. If it's not, I thought it might be best to be very clear and upfront just how much pain you're in for if you decide to start building your own binaries.

share|improve this answer

The patch command takes the patch on standard input. I suggest first always running patch first with "--dry-run" to make sure the patch will apply cleanly before actually modifying files:

patch --dry-run < /path/to/patch

This should prompt you for which file it is trying to patch. If the patch applies cleanly, you can remove --dry-run to actually apply the patch. If the patch doesn't apply cleanly, it means the patch was generated for a different version of the software than what you are patching.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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