Upgrading to MySQL 5.0.27 on RHEL and CentOS

December 5, 2006 by · 23 Comments 

One of the most common technical recommendations given on the vbulletin.com forums is to upgrade your software versions to the newest available. I've already covered how to upgrade Apache's httpd and PHP so now I'm going to explain how to upgrade your RHEL/CentOS 4 system to use MySQL 5.0.27. This is not a terribly difficult process but it is VERY time consuming. Expect to spend about 10 minutes prepping and about an hour compiling (even on a high-end box).

To start, you'll need three things. First, you're going to need 'root' access to your server. If you don't have it, even if you can build the RPMs, you won't be able to install them. Second, on most machines, you'll need to install a huge list of dependencies. Finally, you'll need the MySQL src.rpm from FC7's development tree.

To start out, if you've never built a src.rpm file before, log in to your server as 'root' and run the following commands:

  • mkdir /usr/src/redhat
  • chmod -R 777 /usr/src/redhat

After that, you can fill the dependencies using one of the commands below. If you installed a "minimal" system then there may be about 30 packages that get pulled in (if you have the 'yum' command, use that, if not, use 'up2date').

  • yum install wget diffutils gcc cpp gcc-c++ make autoconf automake rpm-build libtool gperf perl time zlib-devel ncurses-devel openssl-devel readline-devel perl-DBI perl-DBD-MySQL
  • up2date -u wget diffutils gcc cpp gcc-c++ make autoconf automake rpm-build libtool gperf perl time zlib-devel ncurses-devel openssl-devel readline-devel perl-DBI perl-DBD-MySQL

Next, switch to a non-root user, download the MySQL 5.0.27 src.rpm and run the following commands:

  • rpm -ivh mysql-5.0.27-1.fc7.src.rpm
  • cd /usr/src/redhat/

Update (1/5/2007): As of 1/1/2007, this src.rpm will no longer compile as-is. You have three choices when it comes to building the package. First, you can disable regression testing by editing the mysql.spec file (which I really wouldn't recommend). Second, you can set the date of your computer to be sometime in 2006 (which would be the easiest solution). Third, you can apply a patch from MySQL bug #25359 using the instructions below.

To apply the patch you will first need to download this patch to your SOURCES folder. After that, edit the mysql.spec file in the SPECS folder. After line 28, add "Patch11: mysql-test-view-2007.patch". After line 121, add "%patch11 -p1". You can now save the file and return to the shell.

From this point on everything is pretty straightforward and you are now ready to build the RPMs. Before we start though, one word of caution. If you are one of those people that builds RPMs as 'root' even when you're told that it's a bad idea, you're going to waste a LOT of time here. This src.rpm will NOT build unless you are a non-root user. As 'root' it will fail during testing after about 45 minutes.

Now that that's out of the way, run the following command and then go watch something on TV.

  • rpmbuild -bb SPECS/mysql.spec

Once that's finished, assuming that there were no errors, you will end up with 5 RPMs in the '/usr/src/redhat/RPMS/i386' folder that you can install as you like. If you're planning on running a MySQL server then you'll need the 'mysql-server' package. If you're planning on connecting to a remote server then you'll only need the 'mysql' package as that contains the client libraries. If you're going to follow one of my PHP guides (Installing PHP 5.1.6, Installing PHP 5.2.0) then you can also install the 'mysql-devel' package and skip the associated section of those how-to's.

That said, you're done! Any questions or comments, let me know.

Digg this story


23 Responses to “Upgrading to MySQL 5.0.27 on RHEL and CentOS”
  1. iDaemon says:

    we must remove older version of mysql before this instruction?

  2. Jason says:

    I had the 5.0.22 version from the 'centosplus' repo installed and did not need to remove it before I built the RPMs. You will want to make sure that you install them with 'rpm -Uvh' though so that your old install is upgraded and not installed next to.

    However, if you are using the RPMs from mysql.com then you may need to remove them first. I couldn't say for sure as I've never used those.

  3. Mark Evans says:


    Thanks for this excellent tutorial, There seems to be a couple of typo's in the instructions.

    erl-DBI prel-DBD-MySQL -> perl-DBI perl-DBD-MySQL

  4. Jason says:

    Whoops... Thanks for the catch!

  5. Kingedgar says:

    Seems like perl-DBD-MySQL depends on libmysqlclient14 and the 5.0.27 sql packages depend on libmysqlclient15... Is there any way around this?

  6. Jason says:

    Try installing the package "mysqlclient14" using yum or up2date.

  7. iDaemon says:

    thanks for instruction.

  8. dacroz says:

    Thanks for the tutorial Jason. My experience so far, installing on CentOS V4.4:

    First, I got a whole bunch of warnings: "user brewbuilder not found, using root instead." I went ahead with it anyway.

    Then it failed with message saying that directory BUILD does not exist. So I created it.

    I went through the whole make, and it failed at the end, because it couldn't find a couple of directories. Maybe because it tried to install as user root instead of brewbuilder? Final errors were:

    error: cannot create /usr/src/redhat/RPMS/i386: No such file or directory
    error: Could not open /usr/src/redhat/RPMS/i386/mysql-5.0.27-1.i386.rpm: No such file or directory

    Then I created user brewbuilder and tried it again. Same result.

    Any help? I'm pretty sure I followed the instructions verbatim. Including completely logging out an logging back in as user brewbuilder.

  9. Jason says:

    If you use these directions then you can NOT build MySQL as 'root'. You must be a non-root user or else the testing phase will fail. Those messages about the user 'brewbuilder' being missing are OK though; the exact name of the non-root user doesn't matter.

    In any case, it seems like the permissions on your /usr/src/redhat directory aren't correct. In the beginning you were supposed to have run "mkdir /usr/src/redhat" (assuming that the folder didn't exist) and "chmod -R 777 /usr/src/redhat" as 'root' and then switched to a non-root user before installing the src.rpm file. Did you do those steps? If so, there shouldn't be any problem with your non-root user creating the necessary directory structure.

    At this point I would wipe out the entire /usr/src/redhat folder and start over. You could go through and check the permissions but it sounds like this is the only src.rpm that has been built so it really shouldn't matter.

  10. Jonathan says:

    Thank you for these tutorials. They really saved me alot of time.

    I followed the directions for upgrading httpd and it worked great.
    I am having just one problem with upgrading mysql.
    I double checked and I am building as a non-root user.

    The build fails a the testing phase with the following:

    view [ fail ]

    Errors are (from /usr/src/redhat/BUILD/mysql-5.0.27/mysql-test/var/log/mysqltest-time) :
    mysqltest: Result content mismatch
    (the last lines may be the most important ones)
    Below are the diffs between actual and expected results:
    *** r/view.result 2006-10-21 03:36:44.000000000 0300
    --- r/view.reject 2007-01-03 12:45:38.000000000 0300
    *** 2686,2697 ****
    v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age`

  11. Jason says:

    Hmmm... I've built that src.rpm on several x86 systems (physical and OpenVZ VEs) and haven't had any testing issues unless I was running as 'root'.

    What OS are you running? Is this x86 or x86_64 (I've been unable to test the latter thus far)? What version of 'gcc' do you have? Have you applied all of the updates available from 'up2date' or 'yum'? Do you already have MySQL installed (client or server) and if 'yes', is 'mysqld' running?

    Finally, if there is a 'config.log' file in your build tree (under "/usr/src/redhat/BUILD/mysql-5.0.27"), can you upload it somewhere and post a link? There may be more information in there that would help.

  12. Jonathan says:

    I am running a fresh install of CentOS 4.4 with all YUM updates.
    I upgraded httpd and php using your tutorials and they work great.
    I had mysql 4.1 that was installed with the OS but removed it using yum before building this.
    I confirmed there is no other MySQL process running.
    I also confirmed there is no leftover libraries from the original MySQL.

    I tried downloading the RPM from the CentOS Dev testing repo and they failed the test also.
    Maybe some library was changed when I upgraded the httpd and php before the mysqld.
    I will reinstall CentOS and try upgrading MySQL first this time.

    Thanks for the help here. I will be back to let you know if it worked or not.

  13. Jason says:

    If that works out for you let me know.  It really shouldn't, but who knows...

  14. Jonathan says:

    Well I did a reinstall of the OS and tried to upgrade mysql first this time but it still won't work.
    Do I need to leave the old MySQL or remove it before I do the upgrade?
    I noticed when I do a "yum install wget diff gcc gcc-c make autoconf automake rpm-build libtool gperf perl time zlib-devel ncurses-devel openssl-devel readline-devel perl-DBI perl-DBD-MySQL" like you have in the instructions it says "package diff not found" and it pulls in mysqllib.

  15. Jason says:

    Wow... Typo... That should be 'diffutils' not 'diff'. I'll update the article.

  16. Jonathan says:

    Does it matter what the name of the non-root user is when building the RPM?

  17. Jonathan says:

    I finally figured it out. It did compile properly but the test that failed was computing the age of a person in the database with the following code:
    INSERT INTO t1(fName, lName, DOB) VALUES ('Hank', 'Hill', '1964-09-29'), ('Tom', 'Adams', '1908-02-14'), ('Homer', 'Simpson', '1968-03-05');
    SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age

  18. Jonathan says:

    I got cut off there. Basically put there is a bug in the test code for VIEW.
    It is expecting the NOW() to be in the year 2006 but it is really January 2007 causing it to fail. When I put the system clock back to a date in 2006 it passed.

  19. Jason says:

    Wow, that's strange. I wonder if that will happen every time you try to build in 2007... I'm going to bed now (it's been a long day) but I'll let the RPM build again overnight. I'm glad you figured it out and thanks for the info.

  20. Jason says:

    Yup, it failed for me in the same spot. I'll look into this and see if I can find an easy way around it, aside from changing the date on your server for the build.

  21. Jason says:

    This is a known bug that affects versions up through 5.0.30. There is a patch available on bugs.mysql.com at the URL below. I've now updated the main post on how to integrate that patch into the build. Keep in mind though that this is only a temporary fix and that when 2008 rolls around, you'll need another patch if you're stilling running the same version and want to use regression testing again (which you probably won't).


  22. Jacek says:

    To build properly the latest MySQL releases you also need to have the package "bison" installed.


Check out what others are saying about this post...
  1. [...] That said, I’ve taken a slightly different approach to this tutorial as compared to my “Upgrade to MySQL 5.0.27″ tutorial. That how-to dealt with rebuilding the src.rpm from the FC7 development tree so that it would work on RHEL & CentOS 4. This how-to uses the spec file from the official MySQL src.rpm for 5.0.27, upgrades the source to 5.0.33, and then adapts it so that it generates RH/Fedora-style RPMs for an easy upgrade. [...]

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!


Note: This post is over 5 years old. You may want to check later in this blog to see if there is new information relevant to your comment.

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. Use of a non-personal web site or blog in the "Web Site" field and/or leaving a comment that is off-topic or inappropriate may result in the comment being edited or removed at the discretion of the site owner.