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.

25 comments on “MySQL Problem: Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted;
  1. Worked like a charm, with the proviso that it needed a “sudo” in front – otherwise, there’s a privilege failure when mysql_upgrade tries to fix the privilege tables.

    But thank you so much for posting – I’ve been tearing my hair out for months on this one!

  2. 0 down vote

    Although you may be correct about the necessity for upgrade, that’s not the only reason this error occurs.

    When the following is called with a query that returns 1 row

    my $rv = $sth_indexq->fetchall_arrayref;

    the following error is reported:

    DBD::mysql::st execute failed: Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50520, now running 50528. Please use mysql_upgrade to fix this error. at …

    However, the real cause of the error was use of fetchall_arrayref instead of fetchrow_arrayref. The following worked without errors:

    my $rv = $sth_indexq->fetchrow_arrayref;

    The data in $rv was only 1 level deep, not 2.

    The mysql_upgrade solution may very well solve this issue, but the simple solution is know your data and use the right retrieval code.

    J.White

  3. I have approved this reply, but it is not really what my post was about. People are getting this error before any query is run at the mysqldump stage. Of course the simple solution would be for mysql to not give such cryptic errors :)

  4. I am using a webhosting company called 000webhost. I just started getting this error message yesterday. I don’t know where or how to get rid of it. I tried running that code of yours in phpmyadmin it said that I had a syntax error.

    HELP!!!

  5. Get in contact with your webhosting company and tell them – if you are not moving databases around then what I posted is not of relevance to you.

  6. so this function wont compromise the integrity of our data? hope you can reply as soon as possible appreciate it very much and Thanks

  7. This is hard to say. Since this error is occurring when you copy over the database to a more recent mysql version you should have a backup of the data on the original machine. I can say that I have not seen any corrupt data in my databases after running the mysql_upgrade.

  8. Could you please tell me how to run command mysql_upgrade –force -uroot -p in PhpMyAdmin panel? Or what else can I do to repair my DB having PhpMyAdmin?

  9. Dave I am not sure how to do this as I don’t use PhpMyAdmin, but there might be a way of getting a console window from within it.

Leave a Reply

Your email address will not be published. Required fields are marked *