Thursday 26 June 2014

Manually Upgrading MySQL

If at all possible, you should use /scripts/mysqlup to do a MySQL upgrade, however, if you need a version of MySQL outside of what they are offering in current cPanel versions, it is possible to upgrade manually.

These are the instructions for performing a manual upgrade of MySQL to 5.1.30, but this typically applies to all versions over 4.1 and higher. Typically it is best to upgrade to whatever the latest stable branch of MySQL is and apply these instructions to install the RPMS.


If this is on a live system, make sure to make backups of the databases.


# mkdir /root/dbbackups

# touch /root/dbbackups/list



for db in `mysql -e ‘show databases’ |awk ‘print $1’ | grep -v Database`



do
# mysqldump –add-drop-table $db > /root/dbbackups/$db.sql && echo $db >> list

done

# mkdir /root/sqllibs

# cp /usr/lib/libmysqlclient.* /root/sqllibs


Do a search for all installed MySQL packages to be removed:

# rpm -qa | grep -i mysql-

This should present a list of 5 or 6 MySQL RPM’s that are installed, likely. Uninstall them one by one with the rpm -e like so:

# rpm -e MySQL-devel-4.1.21-0.glibc23

Some packages are dependencies of each other, so you may need to remove one before being able to remove another.


Download the binaries for the OS version and MySQL version you are using from the cPanel repo:


http://httpupdate.cpanel.net/mysqlinstall/


execute rpm -i for each package (ex: pm -i MySQL-client-5.1.30-0.glibc23.i386.rpm)


Edit /var/cpanel/cpanel.config and change the MySQL version to 5.1 (or whatever version you’re running now). Then run this command:

# touch /etc/mysqlupdisable

This will keep cPanel from resetting or reverting back to its original MySQL version during updates.


Restart MySQL first to make sure that it can at least start (which it should). Once you’ve verified this, run mysql -V to make sure that the correct version is installed. You should see output similar as below:

root@server [~]# mysql -V

mysql Ver 14.13 Distrib 5.1.30-beta, for pc-linux-gnu (i686) using readline 5.0


MySQL should now be up and running, but it’s likely that trying to log in directly as the root user will fail. Before Following the below steps, make sure you can do a ‘mysql -u root’ and log in successfully. If not, you’ll need to set the root password. By default, MySQL has a blank root password which will need to be set to ours…twice.


Recopy the libs, but don’t overwrite any that already exist:

# mv /root/sqllibs/libmysqlclient.* /usr/lib/mysql/

Next update cPanel’s PHP and DBD MySQL bundle for perl by executing the following:

# /scripts/perlinstaller –force Bundle::DBD::mysql

# /scripts/makecpphp


Verify that phpMyAdmin and php -m load properly and without errors.






Manually Upgrading MySQL

No comments:

Post a Comment