After a fresh installation of MySQL, you may experience system lag from time to time if your VM is just an entry level product. If you have ever wondered and checked system resource usage by free or top command, you may be astonished to find that mysqld takes nearly 400MiB of memory, which is a huge burden for some entry level VM.

Also, this setup is an overkill for most personal projects which usually has visitors less than 100 per day. Fortunately, there is an easy and effective solution for this problem. We only need to disable MySQL's performance schema to get our memory freed. Performance schema is a monitoring feature which can provide you with detailed information about server execution and resource usage. You can check their official document to dive deeper into the topic.

In order to disable the performance schema, we only need to write the following lines into /etc/mysql/my.cnf .

[mysqld]
performance_schema = 0

This tells MySQL to disable performance schema. After editing the configuration file. We need to restart MySQL service.

$ sudo systemctl restart mysql

At this point, if check memory usage again, we will happily find that the memory consumption is nearly cut off by half. This is a huge improvement. Now, we can enjoy using our VM smoothly again!