# Column count of mysql.user is wrong. Expected 45, found 48.

**URL:** <https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646>\
**Category:** Other MySQL® Questions\
**Created:** [May 30, 2017, 6:11pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646 "2017-05-30T18:11:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlex](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@rlex](https://forums.percona.com/u/rlex)\
**Post date:** [May 30, 2017, 6:11pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/1 "2017-05-30T18:11:07Z")

</div>

Debian 8 and ubuntu 16.04 (same percona server version). Versions:

ii percona-release 0.1-4.jessie all Package to install Percona gpg key and APT repo  
ii percona-server-client-5.7 5.7.18-15-1.jessie amd64 Percona Server database client binaries  
ii percona-server-common-5.7 5.7.18-15-1.jessie amd64 Percona Server database common files (e.g. /etc/mysql/my.cnf)  
ii percona-server-server-5.7 5.7.18-15-1.jessie amd64 Percona Server database server binaries

This started to happen after upgrade to 5.7.18 (works fine on .17) - i can’t edit permissions. Anything related to permissions (grant, create user, etc) will fail with “ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 45, found 48. The table is probably corrupted”. And yes, i run mysql\_upgrade after upgrade.

Current mysql.user table structure:

| Host | User | Select\_priv | Insert\_priv | Update\_priv | Delete\_priv | Create\_priv | Drop\_priv | Reload\_priv | Shutdown\_priv | Process\_priv | File\_priv | Grant\_priv | References\_priv | Index\_priv | Alter\_priv | Show\_db\_priv | Super\_priv | Create\_tmp\_table\_priv | Lock\_tables\_priv | Execute\_priv | Repl\_slave\_priv | Repl\_client\_priv | Create\_view\_priv | Show\_view\_priv | Create\_routine\_priv | Alter\_routine\_priv | Create\_user\_priv | Event\_priv | Trigger\_priv | Create\_tablespace\_priv | ssl\_type | ssl\_cipher | x509\_issuer | x509\_subject | max\_questions | max\_updates | max\_connections | max\_user\_connections | plugin | auth\_string | password\_expired | is\_role | default\_role | max\_statement\_time | password\_last\_changed | password\_lifetime | account\_locked |

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jrivera](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jrivera/32/13_2.png) [@jrivera](https://forums.percona.com/u/jrivera)\
**Post date:** [May 30, 2017, 8:51pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/2 "2017-05-30T20:51:27Z")

</div>

From which Percona Server version did you upgrade from? We would like to reproduce the issue on a local test instance so if you can share a reproducible test case with details that would help a lot.

---

<div class="post-metadata">

**Author:** ![rlex](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@rlex](https://forums.percona.com/u/rlex)\
**Post date:** [May 31, 2017, 3:12am UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/3 "2017-05-31T03:12:40Z")

</div>

Can’t really say, this is old servers. One is probably from mysql 5.0 (i know i had it from 2013), second was upgraded from 5.5.

---

<div class="post-metadata">

**Author:** ![jrivera](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jrivera/32/13_2.png) [@jrivera](https://forums.percona.com/u/jrivera)\
**Post date:** [May 31, 2017, 6:50am UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/4 "2017-05-31T06:50:45Z")

</div>

So it’s an in-place upgrade from an old version to the latest 5.7 version. Can you share the details of your steps to upgrade? What operating system and other details.

---

<div class="post-metadata">

**Author:** ![rlex](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@rlex](https://forums.percona.com/u/rlex)\
**Post date:** [June 1, 2017, 2:12pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/5 "2017-06-01T14:12:19Z")

</div>

One is ubuntu 16.04, pretty fresh machine (around 6 month or so)  
Second is debian 8 now, was started… i think from debian 6 and dist-upgraded all the way to 6.  
Upgrade is done with apt-get safe-upgrade, mysql\_upgrade, service mysql restart

---

<div class="post-metadata">

**Author:** ![rlex](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@rlex](https://forums.percona.com/u/rlex)\
**Post date:** [June 1, 2017, 2:18pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/6 "2017-06-01T14:18:45Z")

</div>

btw, what is my options in that situations beside dumping & restoring all databases, and recreating all permissions manually? not a mission critical servers, but if there any way i can adjust scheme without that…

---

<div class="post-metadata">

**Author:** ![blackangelc](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@blackangelc](https://forums.percona.com/u/blackangelc)\
**Post date:** [September 2, 2017, 2:19pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/7 "2017-09-02T14:19:06Z")

</div>

Hi Together,

i migrated from MariaDB (MySQL 5.6) to Percona 5.7 cause wsrep cluster was not working well with MariaDB. Without mysql\_upgrade all worked fine but i got always notices in MySQL Error Log. After i upgraded the tables with mysql\_upgrade i had the same issue. Is there any solution yet to fix it?

I guess there is something in an other table which is relating to mysql.user. Do you have any solution yet or a hint where i can look at?

Thanks and best regards,  
blackangelc

---

<div class="post-metadata">

**Author:** ![blackangelc](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@blackangelc](https://forums.percona.com/u/blackangelc)\
**Post date:** [September 13, 2017, 11:11am UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/8 "2017-09-13T11:11:46Z")

</div>

Hi,

i could solve the problem. I installed on a docker container Percona 5.7 “Vanilla” and dumped the structure of the user table:

```auto
mysqldump --no-data --lock-tables=false mysql user > mysql_user_vanilla.sql

```

I did the same on the host where the schema was broken and diffed the 2 servers:

```auto
> diff -uNp mysql_user_broken.sql mysql_user_vanilla.sql
--- mysql_user_broken.sql 2017-09-13 18:29:18.184767699 +0200
+++ mysql_user_vanilla.sql 2017-09-13 18:25:59.927760416 +0200
&#64;&#64; -1,8 +1,8 &#64;&#64;
--- MySQL dump 10.13 Distrib 5.7.18-15, for debian-linux-gnu (x86_64)
+-- MySQL dump 10.13 Distrib 5.7.19-17, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: mysql
-- ------------------------------------------------------
--- Server version 5.7.18-15-57-log
+-- Server version 5.7.19-17

/*!40101 SET &#64;OLD_CHARACTER_SET_CLIENT=&#64;&#64;CHARACTER_SET_CLIENT */;
/*!40101 SET &#64;OLD_CHARACTER_SET_RESULTS=&#64;&#64;CHARACTER_SET_RESULTS */;
&#64;&#64; -14,11 +14,10 &#64;&#64;
/*!40014 SET &#64;OLD_FOREIGN_KEY_CHECKS=&#64;&#64;FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET &#64;OLD_SQL_MODE=&#64;&#64;SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET &#64;OLD_SQL_NOTES=&#64;&#64;SQL_NOTES, SQL_NOTES=0 */;
-/*!50717 SET &#64;rocksdb_bulk_load_var_name='rocksdb_bulk_load' */;
/*!50717 SELECT COUNT(*) INTO &#64;rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'session_variables' */;
-/*!50717 SET &#64;rocksdb_get_is_supported = IF (&#64;rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO &#64;rocksdb_is_supported FROM performance_schema.session_variables WHERE VARIABLE_NAME=?', 'SELECT 0') */;
+/*!50717 SET &#64;rocksdb_get_is_supported = IF (&#64;rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO &#64;rocksdb_is_supported FROM performance_schema.session_variables WHERE VARIABLE_NAME=\'rocksdb_bulk_load\'', 'SELECT 0') */;
/*!50717 PREPARE s FROM &#64;rocksdb_get_is_supported */;
-/*!50717 EXECUTE s USING &#64;rocksdb_bulk_load_var_name */;
+/*!50717 EXECUTE s */;
/*!50717 DEALLOCATE PREPARE s */;
/*!50717 SET &#64;rocksdb_enable_bulk_load = IF (&#64;rocksdb_is_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET &#64;rocksdb_dummy_bulk_load = 0') */;
/*!50717 PREPARE s FROM &#64;rocksdb_enable_bulk_load */;
&#64;&#64; -71,12 +70,9 &#64;&#64; CREATE TABLE `user` (
`max_questions` int(11) unsigned NOT NULL DEFAULT '0',
`max_updates` int(11) unsigned NOT NULL DEFAULT '0',
`max_connections` int(11) unsigned NOT NULL DEFAULT '0',
- `max_user_connections` int(11) NOT NULL DEFAULT '0',
+ `max_user_connections` int(11) unsigned NOT NULL DEFAULT '0',
`plugin` char(64) COLLATE utf8_bin NOT NULL DEFAULT 'mysql_native_password',
`authentication_string` text COLLATE utf8_bin,
- `is_role` enum('N','Y') COLLATE utf8_bin NOT NULL DEFAULT 'N',
- `default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
- `max_statement_time` decimal(12,6) NOT NULL DEFAULT '0.000000',
`password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`password_last_changed` timestamp NULL DEFAULT NULL,
`password_lifetime` smallint(5) unsigned DEFAULT NULL,
&#64;&#64; -98,4 +94,4 &#64;&#64; CREATE TABLE `user` (
/*!40101 SET COLLATION_CONNECTION=&#64;OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=&#64;OLD_SQL_NOTES */;

--- Dump completed on 2017-09-13 18:29:18
+-- Dump completed on 2017-09-13 16:24:55

```

After it i executed the following commands and could create user again:

```auto
mysql> alter table user drop column is_role;
mysql> alter table user drop column default_role;
mysql> alter table user drop column max_statement_time;
mysql> alter table user modify max_user_connections int(11) unsigned NOT NULL DEFAULT '0';
mysql> flush privileges;

```

I hope this way helps also other people to find out which columns are wrong.

Best regards  
blackangelc

---

<div class="post-metadata">

**Author:** ![Oloremo](https://avatars.discourse-cdn.com/v4/letter/o/c77e96/32.png) [@Oloremo](https://forums.percona.com/u/Oloremo)\
**Post date:** [October 9, 2017, 12:44pm UTC](https://forums.percona.com/t/column-count-of-mysql-user-is-wrong-expected-45-found-48/5646/9 "2017-10-09T12:44:43Z")

</div>

Hi, [jrivera](https://percona.vanillacommunities.com/profile/x/x/21266), in case you’re still interested, I found a 100% reproducible case for this issue.

Scenario:  
mariadb-10.1.14 upgrade to Percona-XtraDB-Cluster-5.7.19-rel17-29.22.1  
Both deployed via tars, not packages.

1. Shutdown maria
2. Deploy Percona
3. Start percona
4. Run mysql\_ugrade
5. Get the following error

Additionally, “sys” database can’t be created via mysql\_upgrade, probably because the same problem with mysql.user
