Upgrading or Downgrading MySQL
Posted by Vanessa | Tagged under howto,mysql | Posted on December 28, 2009
4
You can easily change the major version of MySQL running on your server, keeping in mind that the actual version will be dependent on what cPanel has released in their repository. You may notice that in WHM > Tweak Settings, where MySQL upgrades and downgrades are usually done, you can no longer downgrade to versions under 5.0, nor (at the time of this writing) can you choose MySQL 5.1. Luckily cPanel gives you a way to get around this.
To change the MySQL version, edit the file /var/cpanel/cpanel.config and look for this line
mysql-version
Then change the version number to the major version that you want to upgrade to. For instance, 4.0, 4.1, 5.0, or 5.1.
Then save the file. To perform the upgrade, you can run either of the following scripts:
/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings
/scripts/mysqlup
Then confirm the new version with the mysql -V command. In most cases, if you upgrade/downgrade between major versions you’ll ‘break’ PHP if PHP is compiled with MySQL support. You may then have to re-run EasyApache to recompile PHP, which will automatically compile with the new libraries. You’ll know if this is necessary when you run the php -m command and get an error like this:
php: /usr/lib64/libmysqlclient.so.15: version `libmysqlclient_15' not found (required by php)
Word to the wise (and the lazy system admin that likes to gun through updates), you should ALWAYS dump all your databases prior to upgrading/downgrading between major versions of MySQL. Here’s a command I use to dump all the databases on the server into a backup folder:
mkdir /root/dbbackups ; touch /root/dbbackups/list
for db in `mysql -e ‘show databases’ |awk ‘{print $1}’` ; do mysqldump –add-drop-table $db > /root/dbbackups/$db.sql && echo $db >> list ; done
Then to re-import after the upgrade/downgrade:
for db in `cat /root/dbbackups/list` ; do mysqldump $db < /root/dbbackups/$db.sql ; done
Notes:
- If the MySQL upgrade fails, you can try a forced reinstall by doing /scripts/mysqlup –force
- In my experience, downgrades to MySQL 4.0 from other versions isn’t always so smooth, and I’ve had to actually move out the entire /var/lib/mysql folder and do a complete reinstall of MySQL. This obviously will remove all the databases, but you may be able to manually move them back into the mysql folder and reimport from your backups
- MySQL 4.0 is not automatically compatible with PHP 5+
Related posts:






sending...
[...] is set to ‘NO’, it means that you don’t have MySQL support and you need to either upgrade MySQL, or if you’re running a manually-compiled version, enable SSL [...]
Just an FYI to everyone that is thinking of downgrading there MySQL in cPanel. This IS GOING TO BREAK A LOT OF STUFF!
Ok, I said my piece.
Downgrading MySQL doesn’t usually break things – but as with any upgrade or downgrade, sites will break if they are not programmed to work outside specific versions.
[...] Upgrading or Downgrading MySQL [...]