Detailed explanation of how to reduce memory usage in MySql

Detailed explanation of how to reduce memory usage in MySql

Preface

By default, MySQL will initialize a large memory block to cache database query data.

But my small host only has 640MB of memory, and top query found that it ate up 30% of my total memory, almost 200MB.

But there are only a few MB of data in this database, and this setting feels unreasonable.

After searching the article, I finally reduced the memory usage to 128MB

Implementation

Modify /etc/mysql/mysql.conf.d/mysqld.cnf directly

Add the following configuration at the end of the configuration

performance_schema_max_table_instances=150
table_definition_cache=150
table_open_cache=64

Then restart the service with service mysql restart

Effect

Before optimization

After optimization

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the my.ini Chinese configuration scheme for MySql optimization: InnoDB, 4GB memory, and multiple queries
  • Briefly describe the MySQL InnoDB storage engine
  • MySQL learning summary: a preliminary understanding of the architectural design of the InnoDB storage engine
  • MySQL Learning (VII): Detailed Explanation of the Implementation Principle of Innodb Storage Engine Index
  • Summary of the differences between MySQL storage engines MyISAM and InnoDB
  • A Deep Dive into the MySQL InnoDB Storage Engine
  • Detailed analysis of MySQL 8.0 memory consumption
  • Detailed explanation of the usage of MySQL memory tables and temporary tables
  • Summary of MySQL 8.0 memory-related parameters
  • Detailed explanation of memory management of MySQL InnoDB storage engine

<<:  VMware and CentOS system installation method to reset the root password

>>:  WeChat applet implements a simple calculator

Recommend

Detailed explanation of the implementation of nginx process lock

Table of contents 1. The role of nginx process lo...

Summary of common Nginx techniques and examples

1. Priority of multiple servers For example, if e...

Detailed explanation of the use of props in React's three major attributes

Table of contents Class Component Functional Comp...

Detailed explanation of the use of Teleport in Vue3

Table of contents Purpose of Teleport How Telepor...

A brief discussion on the problem of forgotten mysql password and login error

If you forget your MySQL login password, the solu...

How to smoothly go online after MySQL table partitioning

Table of contents Purpose of the table For exampl...

Docker-compose creates a bridge, adds a subnet, and deletes a network card

1. Create a docker network card [root@i ~]# brctl...

js to achieve 3D carousel effect

This article shares the specific code for impleme...

Practical Optimization of MySQL Paging Limit

Preface When we use query statements, we often ne...

JavaScript Basics: Immediate Execution Function

Table of contents Immediately execute function fo...

React implements multi-component value transfer function through conetxt

The effect of this function is similar to vue的pro...

Detailed explanation of Linux command unzip

Table of contents 1. unzip command 1.1 Syntax 1.2...

Docker enables multiple port mapping commands

as follows: docker run -d -p 5000:23 -p 5001:22 -...