Table 'performance_schema.session_variables' doesn't exist
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The error message "Table 'performance_schema.session_variables' doesn't exist" is commonly encountered when interacting with MySQL's Performance Schema, a valuable tool for database administrators and developers to monitor MySQL server performance and diagnostics. Understanding what triggers this error and how to resolve it is crucial for maintaining a robust and efficient database environment. This article delves into the reasons behind the absence of this table and provides solutions for handling this error.
Understanding the Performance Schema
Performance Schema is an instrumentation facility in MySQL used to collect performance metrics. It's crucial for diagnosing issues, optimizing queries, and systematically analyzing how the database performs under various loads. Performance Schema comprises multiple tables that extract specific performance data, one of which is the performance_schema.session_variables table.
Why the Error Occurs
The specific error "Table 'performance_schema.session_variables' doesn't exist" typically means that the MySQL server's Performance Schema either doesn't have the expected table configured or that the related tables haven't been initialized correctly. Here are several common reasons why this error might be encountered:
- Version Incompatibility: Not all MySQL versions contain the same Performance Schema tables. It's possible you're using a version that does not support
session_variables. - Disabled Performance Schema: If the Performance Schema is disabled in the server configuration, the table won't be available.
- Incorrect Initialization: On some occasions, the Performance Schema tables are not initialized properly during server startup.
- Corrupted Tables: Corruption due to system crashes, unexpected shutdowns, or filesystem issues might lead to missing Performance Schema tables.
Solutions and Workarounds
Verify MySQL Version
First, ensure your MySQL version supports the performance_schema.session_variables table. Some older versions may lack this feature. You can check your MySQL version using the following command:
Enable Performance Schema
Ensure that the Performance Schema is enabled in your MySQL configuration file (my.cnf or my.ini). Add or verify the following lines:
Make sure to restart the MySQL server after making changes to the configuration file.
Initialize Performance Schema Tables
If the tables are missing, you may need to initialize the Performance Schema. Although it typically auto-initializes upon MySQL startup, you can manually do so by ensuring the SQL mode allows for table creation:
- Start the MySQL shell:
- Execute the following command:
Repair Corrupted Tables
If you suspect table corruption, first verify and then attempt to repair the tables using the REPAIR TABLE command. However, typical Performance Schema tables may not respond to this command given their virtual and transient nature. Reinitialization (as above) is usually more effective here.
Advantages of Preventive Measures
Preventative measures such as regular backups, monitoring MySQL logs, and keeping your system and software updated can prevent many underlying causes of missing tables. Setting up alerts for Performance Schema warnings can preemptively catch and address server issues before they escalate.
Summary Table
| Key Point | Explanation |
| Performance Schema Purpose | Tracks server performance and diagnostic metrics. |
| Error Cause | Versions not supporting table, disabled schema, or corrupted tables. |
| Solution to Enable Performance Schema | Edit configuration files and ensure performance_schema = ON. |
| Initialization Command | Reinitialize tables if missing using TRUNCATE and CREATE TABLE syntax. |
| Version Check Command | SELECT VERSION(); to verify MySQL version suitability. |
Conclusion
Understanding how to troubleshoot the absence of the performance_schema.session_variables table helps maintain efficient database operations and leverage MySQL's full capabilities. By ensuring compatibility, enabling features, and reinitializing tables when needed, database administrators can effectively manage and monitor server performance.
Related reading
- Table primary key uniqueness across different / multi-region Amazon RDS postgres
- Table replication materialized view Oracle
- Table storage engine for TABLE doesn't have this option on order by query ERROR 1031
- Techniques to ensure cluster wide consistency at distributed databases
- TableView slow when adding images to cellForRowAtIndex
- Tail Recursion optimization for JavaScript?
- Tailing few lines from huge logs of kubectl logs -f
- tar Unrecognized archive format error when trying to unpack flower_photos.tgz, TF tutorials on OSX

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.