Upgrading to MySQL 5.1
Categories: MySQL, Upgrading Software.
This tutorial is taken from our sister site, v-nessa.net
Note that at the time of this writing, cPanel does not provide support for MySQL 5.1, but a manual upgrade is still possible. This upgrade process has been tested under cPanel 11 EDGE build with Apache 2.2.4.
*Always back up your databases before doing a MySQL upgrade!
1. Copy the MySQL libraries from the server into a temporary location:
mkdir /root/sqlibs
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:
Go 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/
When you recompile Apache and PHP, make sure to NOT compile with ’system mysql’. Note that the cPanel Apache build does not include MySQL 5.1 php extensions, so the latest will be loaded. This should not cause any problems.