#1805 – Column count of mysql.user is wrong expected 45 found 42. The table is probably corrupted
While working on Mysql to create an new user it throws above error and could not able to create
mysql user even I tried from terminal window. Image – 1
Image – 1
As the error is column count of mysql.user is wrong expected 45 and found 42. so to check with another
same mysql version mysql.user column count.
I just installed same version mysql 5.7.23 in another temp machine and could find 45 columns in mysql.user table.
where 3 columns missing here in this mysql.user table.
Solutions came to my mind
1 – To take backup of database and reinstall mysql 5.7.23 version again but to install you need to use apt-get install command, which will install the updated version of any package may create more error in the server.which I didn’t follow.
2 – To run upgrade command like apt-get upgrade mysql-server5.7.23, while running upgrade it will check for missing things and fix. which I didn’t follow because it may create more error in the server by updating any package.
3 – I just tried to add those columns manually which also didn’t work.
4 – Finally I thought to replicate same error in the temp machine and to try for the fix.
5 – I took whole database dump backup and restored in the temp machine and to my surprise I could get same error as like in server while creating mysql user.
you may also like :- How to take mysql database dump and restore and also to take database individually backup.
6 – Then after much research I could find a command which solved the error.
I just ran this command mysql_upgrade -u root -p
and I could now able to create mysql user and assign privilege to the user without any issue. – Image – 2
Image – 2
Also there is another command which also worked sudo dpkg-reconfigure mysql-server-5.7
as shown in Image – 3
Image – 3
So you can apply any of the above solution to fix the above error.
You may also like : –
VPN Connection issue in Windows 10
How to resolve network wifi issue in Ubuntu 16.04 LTS
Creating Local Yum Repository on Red Hat Enterprise linux 6
Install and configure Jasper Report Server on Ubuntu Server
How to install PHP7.1 and PHP 5.6 in Ubuntu 14