MySQL Problem: Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted;

I was dumping and importing MySQL databases between my production server which had MySQL 5.0.95  and my test server which had MySQL 5.1.61 and was getting the error “Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted;” on the test server with the copied over database.

To make a long story short apparently there is some bug in MySQL that causes this rather cryptic error when moving a database created by 5.0 to 5.1. To fix this problem you need to run the following command as root (or use sudo) on the server you have migrated the database.

mysql_upgrade --force -uroot -p [your mysql root password]

You have to use the –force option or else the upgrade won’t fix the problem. I hope this saves someone a little time.

Removing all files older than X days

This is just a little linux command line hack for removing all files older than X days (Substitute the X for the number of days):

find /[path]/* -mtime +X -exec rm -rf {} \;

eg “find /var/www/html/* -mtime +3 -exec rm -rf {} \;” to delete all files in the html directory older than 3 days.

Before running this you can also check what will be deleted by running the following:

find /[path]/* -mtime +X -exec ls -la {} \;