Featured Posts

Tips to Reduce Your Customer Support Costs When hosting websites, whether as a mainstream hosting provider, a hobby, or to supplement another service, it's your job to make sure your customers have access to technical support in case they need...

Read more

Roundcube: MySQL or SQLite? cPanel 11.25 introduces a new feature: The ability to have RoundCube use SQLite instead of MySQL. After benchmarking resource usage and performance, I've come to the conclusion that SQLite is definitely...

Read more

Simple Bash Script to Fix Account Permissions This is a simple bash script I wrote to fix the permissions and ownership of files within a cpanel account. To use, simply copy the script your server, chmod 755, and pass the usernames as arguments: ./fixperms...

Read more

Re-Installing Auxiliary cPanel Software Cpanel has a lot of supporting software that you may be using on your server. In case something goes amiss, here is a list of scripts that reinstall cpanel-provided software on your system. For most all...

Read more

10 Free Monitoring Solutions to Consider Server and network monitoring can be crucial to a host's success. I mean, how embarrassing is it when your customers are aware of downtime before you are? You don't have to pay big bucks or spend loads...

Read more

The cPanel Admin Rss

Upgrading or Downgrading MySQL

Posted by Vanessa | Tagged under , | 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+
Liking this article? Share it and spread the word!
  • Print
  • PDF
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts:

Comments (4)

[...] 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 [...]

Write a comment