Two days ago I had started work to upgrade the database on the development server. We plan to use Amazon’s RDS (Relational Database Server) which only runs limited versions for MySQL. As of this writing they are 5.5.8, 5.1.50, 5.1.49 and 5.1.48. Before I was running MySQL 5.0 on both the development and production servers. As a web developer, I know it is best to use the same MySQL and PHP versions on the development server and the production server. This way, after you have tested and developed your code on the dev box you can rule out any problems you might encounter when you upload your code to production due to different versions of PHP or MySQL. It is also a good idea to match Apache versions but not too important to match Linux kernels or distributions, at least not in my line of work.
I usually use packages to install programs on the Linux boxes as I use Debian. Currently, I am using Debian Lenny (version 5.0) on both boxes. I have used packages to install everything except PHP. The Debian Lenny stable packages for MySQL are only for MySQL 5.0 but I needed to upgrade that so I could match the MySQL version that will be used on Amazon’s RDS. I searched the Debian site and came across Debian Backports. This is an answer to using newer packages that aren’t available to Lenny. I found that Backports has a package for MySQL 5.1.49. I thought, “perfect,” now I can just install MySQL Backports package for Lenny and now my database versions would be the same.
I had to modify my /etc/apt/sources.list to include:
deb http://backports.debian.org/debian-backports/ lenny-backports main
This was the right thing to do because when I went into aptitude and did a package update I was able to find the MySQL server and client 5.1.49. I went ahead and removed (purged) the old MySQL 5.0 packages and installed the following packages:
mysql-server-5.1 mysql-client-5.1 libmysqlclient-dev libmysqld-dev
Each version was 5.1.49.
During install it asked me if I wanted to overwrite my my.cnf file. I guess I should have let it change it because when it tried to restart MySQL failed to start. I then kept trying to reinstall so it would go ahead and overwrite my old my.cnf file. I had to find an example MySQL conf file which can be located in /usr/share/doc/mysql-server-5.1/my-*.cnf. These files are example MySQL conf files for various size database servers. I chose the medium configure file as that best matched my old conf file. Doing so seemed to work as I was able to get MySQL running again.
I then went to access phpMyAdmin and it brought up a warning about how the PHP client didn’t match the MySQL version. So I knew I had to recompile PHP. I had used packages for everything except PHP because I had to customize PHP so much. I opened up a PHP dev file that uses the function phpinfo(). There I had the complete ./configure line that I used to originally compile PHP. After I ran the configure again, I ran make && make install. This went pretty fast but I didn’t think much of it. When I went to access my website I kept getting this error:
mysql_connect(): Headers and client library minor version mismatch
This one was the doozy. I searched and searched all over the internet to find an answer. I found a few things here and there which didn’t help. Everything I found is stuff I already did. I knew I had installed MySQL correctly with aptitude. I thought I was compiling PHP correctly. I couldn’t figure out why the PHP compilation was not using the new MySQL header code.
So after literally 8 hours of web searches, trial and error, and chatting on IRC with the nice guys at Cerberus who offer a CRM toolkit, I finally got my prayer answered. Yes, I said prayer. I prayed about it while in the bathroom. While chatting, I had asked how to remove something that was installed via a compile. He said to,
try make clean.
I tried it, it seemed to remove some things. Wouldn’t you know it, while running make && make install, it took considerably longer. I figured something new must be happening here. Apparently, that did the trick. I guess it recompiled the header files this time all the way around and overwrote the old ones that were left behind from the very first compile I did while I had MySQL 5.0 installed.
I really, really hope this post saves someone else a day’s work. If so, hit me up!