MySQL: Table 'performance_schema.session_variables' doesn't exist
ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't existShort answer
This error means the server and its performance_schema do not match, which is what an unfinished upgrade looks like. Start the server with upgrades allowed. MySQL 8.4 upgrades the data dictionary, Performance Schema and system tables itself on start. If --upgrade is set to NONE or MINIMAL, remove it or use FORCE once.
Fix it fast
1Find out which cause you have
Check the server version and whether the table exists. If the table is missing on a freshly upgraded server, the upgrade may not have completed.
mysql -u root -p -e "SELECT VERSION(); SELECT COUNT(*) FROM performance_schema.session_variables;"2Match what you see, then jump to its fix
- 1
The error log says the server is shutting down because upgrade is required but prohibited by --upgrade=NONEThe server was started with upgrades turned offFix - 2
Other performance_schema tables are also missing or old, and no upgrade error is loggedThe upgrade ran partly, and the Performance Schema was not rebuiltFix
- 1
What does the error look like?
ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't existTable 'performance_schema.session_variables' doesn't exist
Cause 1 of 2
The server was started with upgrades turned off
1Check
With --upgrade=NONE the server upgrades nothing and exits if the data dictionary is out of date. With MINIMAL, the system tables are not updated. Look for the option in the service config.
grep -r -n -i "upgrade" /etc/mysql/ /etc/my.cnf /etc/systemd/system/mysql.service.d 2>/dev/null2Fix
Remove the option so the default AUTO applies, then restart and let the server finish the upgrade.
sudo systemctl restart mysql
sudo tail -n 40 /var/log/mysql/error.log3Verify
The query now returns a number.
mysql -u root -p -e "SELECT COUNT(*) FROM performance_schema.session_variables;"Confirmed by dev.mysql.com
Cause 2 of 2
The upgrade ran partly, and the Performance Schema was not rebuilt
1Check
The upgrade covers the data dictionary, Performance Schema and INFORMATION_SCHEMA in step 1, and the mysql system tables and sys schema in step 2. FORCE repeats both steps and checks every object.
mysql -u root -p -e "SHOW TABLES FROM performance_schema LIKE 'session%';"2Fix
Run one start with --upgrade=FORCE, wait for it to finish (it can be slow on large schemas), then go back to the normal command. Take a backup of the data directory first.
sudo systemctl stop mysql
sudo -u mysql mysqld --upgrade=FORCE
# stop it after it reports ready, then start the service normally3Verify
The tables are listed and the query works.
mysql -u root -p -e "SHOW TABLES FROM performance_schema LIKE 'session%';"Confirmed by dev.mysql.com
How do I stop it coming back?
- Back up the data directory before every major or minor version upgrade.
- Let the server run its own upgrade on first start and read its error log before you start the app.
- Do not mix binaries of different versions over one data directory.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fixDatabases
An Aria table fails with 'Read page with wrong checksum' (error 1030, code 176)
ERROR 1030 (HY000): Got error 176 "Read page with wrong checksum" from storage engine Aria
Code 176 means MariaDB's Aria engine read a data or index page whose checksum does not match, so that table file is damaged.
3 causes, each with a fixDatabases
The client cannot open a TCP connection to MariaDB or MySQL (error 2003)
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
Error 2003 means the client tried a TCP connection to the host and port and nobody answered.
4 causes, each with a fix