Handling MySQL error 1682 (HY000): Native table 'performance_schema'.'session_variables' has the wrong structure


1. Introduction

The following article explain how to solve “Native table performance_schema has wrong structure”. This is related to Core-Admin event reported

  • mysql_performance_schema_wrong_structure: in case core-admin agent detects this problem, this event will be reported:


2. Description

Steps that describe the problem and how to resolve it:

  1. During MySQL installation with MySQL, you might find the following error:

    ERROR 1682 (HY000): Native table 'performance_schema'.'session_variables' has the wrong structure
  2. Then try to upgrade mysql server using binaries provided by the mysql server installation:

    >> /path/to/mysql/5.7/bin/mysql_upgrade --defaults-file=/root/.mysql_secret-5.7 

    It should complete without error. That will be indicated by the command. It might happen MySQL server is already upgraded. In such case you will get something like:

     This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade

    Do not force. It means it was upgraded but for some reason, it was not restarted. Try first to restart before forcing anything.

  3. Restart MySQL server upgraded to make changes to take effect:

    >> /etc/init.d/mysql-5.7 restart
  4. After this, try again to run query that was failing with this error.