After a migration from mariadb to mysql-community, I have this error when I try to grant new users:

ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 43,

found 45. The table is probably corrupted

As I got the backup from as server I didn't own, I do'nt know the exact version of maria-db. But my mysql-server version is: community-server-5.6.38-2

解决方案

I tried the solution posted on a lot of forums

mysql_upgrade --force -uroot -p

But this didn't give the expected results.

So I comparated the fields list from a brand new mysql community server and mine. And discovered that the 3 problematic fields where:

is_role

default_role

max_statement_time

So I did:

mysql -e "ALTER TABLE mysql.user DROP COLUMN is_role, DROP default_role, DROP max_statement_time" -uroot -p

And this worked

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐