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.
the above solution work for me..Thanks it great help for me..
Thanks a mil, Daniel. Your post helped me.
It works for me too.
Thanks a lot it works for me as well
Thanks. This information is really useful.
Thank you, this really helped :)
Thank you very much, but i very glad because my problem was lost with you solution , salam 86
Thank you for sharing. Solved my mysqldump issue.
thanks dear it worked for me.
Thank you so much!
worked like a charm.
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!
worked for me on mysql 5.5 community edition…
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.
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 :)
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.
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.
thank you. it works :)
so this function wont compromise the integrity of our data? hope you can reply as soon as possible appreciate it very much and Thanks
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.
thank you man,its working at me
Ty so much
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?
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.
Cool fix! Thanks for sharing.
it works for me, thank you