Resolving performance_schema Issues in MySQL


During daily work with MySQL databases, specific challenges such as missing tables or errors related to the unrecognized database performance_schema can arise. These problems can significantly affect the performance and stability of database systems, and their diagnosis and resolution can often be complicated and time-consuming. To facilitate this task, I have created this guide, which is the result of my experiences and proven practices. I provide a comprehensive approach to identifying and fixing issues related to performance_schema. It’s quite simple to import the schema from a newly built database.

Of course, it’s best to perform a backup of the database before the entire operation.

Initial Diagnosis in MySQL

Start by identifying the problem in the MySQL shell:

Creating New Performance Schema in MySQL

Create a new performance schema from the MySQL command line:

Server Operations to Establish New MySQL Environment

Return to the system to configure a clean MySQL environment:

Then, start MySQL in safe mode to configure it – without external network interruptions:

Configuration and Verification in MySQL

Return to the MySQL command line to verify the configuration and configure the new database:

As you can see, here performance_schema is working correctly.
Update the root password in the MySQL environment to secure the new installation:

Restart MySQL in safe mode to ensure all configurations are applied:

Configure MySQL Server to Run New Database

After securing the new MySQL configuration, update the server configuration to use the new data directory:

Restart the MySQL service to load the my.cnf file during mysql startup:

Export and Restore Performance Schema in MySQL

With the new configuration, export performance_schema using MySQL commands and prepare for its restoration:

It’s necessary to shut down MySQL:

Restore the original MySQL data directory on the server, restart the MySQL service, and import the exported schema:

Make sure the default storage engine is running, e.g:

Don’t forget to remove the trash:

If you’ve reached this point, remember to delete the database backup – as long as everything is working. You did make one, right? 🙂