If you have server that run on cPanel, you’ll probably know how big of a Nazi it is in regards to the MySQL versions it can run. We just got this new line of servers at work and one of them I was pretty heartset on installing MySQL 5.1, mainly because of its loadable plugin features where you can install a plugin or module without having to recompile the whole damn thing. Upgrading to 5.1 is easy, you just have to follow the right steps.
First, I would recommend upgrading to cPanel 11 or EDGE, which should have support for compiling Apache with non-supported versions of MySQL. On this server, I’m currently running 11 on the bleeding edge build. Also, it’s a splendid idea to dump all your databases before upgrading.
Note that these instructions mention MySQL 5.1.20-beta because that’s the latest release available at the time of my writing….but you can essentially follow this guide for any version of MySQL!
1. Copy the MySQL libraries from the server into a temporary location:
mkdir /root/sqllibs
cp /usr/lib/libmysqlclient.* /root/sqllibs
2. Find any installed MySQL packages:
rpm -qa | grep -i mysql-
This should present a list of installed rpm’s…remove them with rpm -e ,but note that some may need to be removed before others. Some people also would remove the /var/lib/mysql directory, but you can leave that there.
3. Download and install the MySQL 5.1.x packages:
Hop on over to http://dev.mysql.com/downloads/mysql/5.1.html#linux-x86-32bit-rpms and download the 5.1 RPM’s and install them:
rpm -i MySQL-client-5.1.20-0.glibc23.i386.rpm
rpm -i MySQL-devel-5.1.20-0.glibc23.i386.rpm
rpm -i MySQL-embedded-5.1.20-0.glibc23.i386.rpm
rpm -i MySQL-test-5.1.20-0.glibc23.i386.rpm
rpm -i MySQL-server-5.1.20-0.glibc23.i386.rpm
4. Prepare cPanel
You’ll want to make sure that cPanel’s updates don’t reset the MySQL version, so you need to run the following commands to force cPanel to skip MySQL updates:
touch /etc/mysqldisable
touch /etc/mysqlupdisable
Now edit /var/cpanel/cpanel.config and change the MySQL version to 5.1
Create the symlink:
ln -s /var/lib/mysql/mysql.sock /tmp
Also, verify that the MySQL version is correct by running mysql -V
root@vps [~]# mysql -V
mysql Ver 14.13 Distrib 5.1.20-beta, for pc-linux-gnu (i686) using readline 5.0
5. Set up MySQL
MySQL should have already been started at this point, so you can attempt to log in as root using mysql -u root . If you are able to log in on the first try, great. If not, you’ll need to reset the MySQL password:
pico /etc/my.cnf
Add this line, and restart MySQL
skip-grant-tables
service mysql restart
Now log into MySQL root and set the password:
mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit;
service mysql restart
When you’re done, remove the skip-grant-tables line from /etc/my.cnf and restart MySQL. Then log into Webhost Manager and reset the password *again*… this is necessary to build a bridge between the linux root user and the MySQL root user, so you can log into MySQL both through WHM’s phpMyAdmin, and SSH without a password when logged into the server as root.
All you need to do now is recompile Apache, but move the MySQL libraries back so easyapache can find them:
mv /root/sqllibs/libmysqlclient.* /usr/lib/mysql/
I haven’t tested too many configurations yet, but what works for me is Apache 2.2.4 with php 5.2.3, compiled with MySQL and mysqli, but NOT system MySQL.

























10 Comments | Add your own
I am running php4.7 and mysql4 on cpanel 11 with Fantastico. I want the latest php5 and mysql5
Which one do I upgrade first, mysql or php5?
Would this affect my fantastico?
You always upgrade MySQL first, then recompile php to reinstall the mysql extensions for php. At the moment cPanel only provides the php ext. for 5.0.24/27 for the MySQL 5 branch, but those will work fine.
This should not affect Fantastico, but there is some software provided in it (like noah’s classified) that does not work well with php 5.
i’m trying to upgrade mysql to 5.1.14 on one of the dedicated servers we host, and I’m getting an error about ‘libmysqlclient.so.14′ missing. Our servers use fedora5 with php 5.1.22 any help you can provide will be appreciated
Depending on where your libs are located, one of these commands should work:
ln -s /usr/lib/mysql/libmysqlclient.so /usr/lib/mysql/libmysqlclient.so.14
or
ln -s /usr/lib/libmysqlclient.so /usr/lib/libmysqlclient.so.14
Hi, while installing the RPMs for mysql, I get this error:
[ericm] #> rpm -i MySQL-test-5.1.21-0.glibc23.i386.rpm
error: Failed dependencies:
perl-DBI is needed by MySQL-test-5.1.21-0.glibc23.i386
Any idea what this is about and what to do? DBI, DBD, Bundle::DBI etc are all installed and updated!
are you on a 64-bit system? You can see these:
http://lso.gmu.edu/OSCR/howtoDBIonLinux.html
http://www.ozzu.com/ftopic1739.html
http://www.directadmin.com/help/item.php?id=98
lately i have upgraded to apache 2.1 and PHP 5.2 it was amazing @ performance it decreased the load on the server also i add eaccelerator for PHP it was really magnificent for work the server right now working as charm i was thinking abou installing MYSQL 5 also Right now i think i wll take this chance to give it try after testing it wll post the result here again tyvm Nessa ilkie this site to much :D <3
Is there a way to easily reverse this incase there are any problems? I’d like to upgrade my setup, but don’t want a live server to be down for hours on end if there is a hiccup I can’t figure out.
Also, does the mysql data and username/password information stay intact?
Thank you so much! This helped me when I thought upgrading was impossible.
One Question:
Why do you install the embedded server in your tutorial? cPanel/Apache uses the client/server model, doesn’t it?
One Trackback/Pingback
[...] Source: http://www.v-nessa.net/2007/07/20/upgrading-to-mysql-5120-on-cpanel ; [...]
Post a Comment