HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

ERROR 1054 (42S22): Unknown column 'plugin' in 'mysql.user'

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
errorcolumnunknownuserpluginmysql105442s22

Problem

I am trying to grant privileges for a user to a new database

mysql> grant all on db_test.* to 'user_test'@'localhost' identified by 'usersexistingpassword';


I get the following error

ERROR 1054 (42S22): Unknown column 'plugin' in 'mysql.user'


I am using MySQL 5.6

mysql> select @@version;
+-------------+
| @@version   |
+-------------+
| 5.6.24-72.2 |
+-------------+
1 row in set (0.00 sec)


I did find an article on MySQL on updating Native Passwords on 5.6.x and later


6.3.9.3 Migrating Away from Pre-4.1 Password Hashing and the mysql_old_password Plugin
https://dev.mysql.com/doc/refman/5.7/en/account-upgrades.html

I ran the command they recommend as root

mysql> UPDATE mysql.user SET plugin = 'mysql_native_password'
    -> WHERE plugin = '' AND (Password = '' OR LENGTH(Password) = 41);
ERROR 1054 (42S22): Unknown column 'plugin' in 'where clause'

Solution

Your problem has to do with mysql.user and the way you upgraded to MySQL 5.6

If you look my answer to Cannot GRANT privileges as root, I show you the description of mysql.user from MySQL 4.1 to MySQL 5.6.

The column plugin is column #41 in mysql.user in MySQL 5.5/5.6

mysql> SELECT column_name,ordinal_position FROM information_schema.columns
    -> WHERE table_schema='mysql' and table_name='user' and column_name='plugin';
+-------------+------------------+
| column_name | ordinal_position |
+-------------+------------------+
| plugin      |               41 |
+-------------+------------------+
1 row in set (0.04 sec)

mysql> SELECT version();
+-----------+
| version() |
+-----------+
| 5.6.24    |
+-----------+
1 row in set (0.02 sec)

mysql>


That column does not appear in MySQL 5.1, 5.0 or 4.x. What this tells me is that somehow MySQL was upgraded to 5.6 but still has the mysql.user from 5.1 or older.

If you run SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user'; and you get 39, I have just the fix for you.

See my post MySQL service stops after trying to grant privileges to a user on how manually fix mysql.user from 5.1 straight to to 5.6.

Code Snippets

mysql> SELECT column_name,ordinal_position FROM information_schema.columns
    -> WHERE table_schema='mysql' and table_name='user' and column_name='plugin';
+-------------+------------------+
| column_name | ordinal_position |
+-------------+------------------+
| plugin      |               41 |
+-------------+------------------+
1 row in set (0.04 sec)

mysql> SELECT version();
+-----------+
| version() |
+-----------+
| 5.6.24    |
+-----------+
1 row in set (0.02 sec)

mysql>

Context

StackExchange Database Administrators Q#103723, answer score: 9

Revisions (0)

No revisions yet.