Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

MySQL: Table 'performance_schema.session_variables' doesn't exist

ErrorERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist

Short 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.

  • Applies to MySQL 8.4, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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;"
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2Other performance_schema tables are also missing or old, and no upgrade error is loggedThe upgrade ran partly, and the Performance Schema was not rebuiltFix

What does the error look like?

  • ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist
  • Table '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/null

2Fix

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.log

3Verify

The query now returns a number.

mysql -u root -p -e "SELECT COUNT(*) FROM performance_schema.session_variables;"

Confirmed by dev.mysql.com

Did this fix it?

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 normally

3Verify

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

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.