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

Two common solutions to html text overflow display ellipsis characters

Method 1: Use CSS overflow omission to solve The ...

Use docker to deploy tomcat and connect to skywalking

Table of contents 1. Overview 2. Use docker to de...

How to add and delete unique indexes for fields in MySQL

1. Add PRIMARY KEY (primary key index) mysql>A...

In-depth exploration of whether Mysql fuzzy query is case-sensitive

Preface Recently, I have been busy writing a smal...

Simple steps to implement H5 WeChat public account authorization

Preface Yesterday, there was a project that requi...

React Native startup process detailed analysis

Introduction: This article takes the sample proje...

One-click installation of MySQL 5.7 and password policy modification method

1. One-click installation of Mysql script [root@u...

Sample code for implementing Google third-party login in Vue

Table of contents 1. Developer Platform Configura...

MySQL cleverly uses sum, case and when to optimize statistical queries

I was recently working on a project at the compan...

Analysis of slow insert cases caused by large transactions in MySQL

【question】 The INSERT statement is one of the mos...

Javascript basics about built-in objects

Table of contents 1. Introduction to built-in obj...

Pitfalls based on MySQL default sorting rules

The default varchar type in MySQL is case insensi...

5 cool and practical HTML tags and attributes introduction

In fact, this is also a clickbait title, and it c...

js to realize the function of uploading pictures

The principle of uploading pictures on the front ...

Windows Server 2019 IIS10.0+PHP(FastCGI)+MySQL Environment Construction Tutorial

Preparation 1. Environmental Description: Operati...