How to shrink the log file in MYSQL SERVER

How to shrink the log file in MYSQL SERVER

The transaction log records the operations on the relevant database and also stores information related to database recovery.

There are many reasons to shrink the log, some due to insufficient space, and some due to application limitations.

The following describes the shrinking operation in simple mode.

1. Command line

USE MASTER
GO
ALTER DATABASE {DBName} SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE {DBName} SET RECOVERY SIMPLE --Simple mode GO
USE {DBName}
GO
DBCC SHRINKFILE (N'{DBName}_Log', 8, TRUNCATEONLY)
GO
USE MASTER
GO
ALTER DATABASE {DBName} SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE {DBName} SET RECOVERY FULL --Restore to full mode

2. Step-by-step operation through the graphical interface

1. Open the database properties window

2. Change the database recovery mode from "full" to "simple"

3. Shrink the database log, "Task" -> "Shrink"

4. After shrinking, change the recovery mode of the database to "full"

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:
  • MySQL series: redo log, undo log and binlog detailed explanation
  • Detailed explanation of MySQL redo log (redo log) and rollback log (undo logo)
  • Summary of 7 types of logs in MySQL
  • MySQL uses binlog logs to implement data recovery
  • Analysis and solution of a MySQL slow log monitoring false alarm problem
  • The role and opening of MySQL slow query log
  • Enabling and configuring MySQL slow query log
  • Undo log in MySQL
  • Detailed explanation of the binlog log analysis tool for monitoring MySQL: Canal
  • Analysis of MySQL Aborted connection warning log
  • Summary of MySQL Undo Log and Redo Log

<<:  Element dynamic routing breadcrumbs implementation example

>>:  Use of Linux sed command

Recommend

Tomcat Nginx Redis session sharing process diagram

1. Preparation Middleware: Tomcat, Redis, Nginx J...

Using react-virtualized to implement a long list of images with dynamic height

Table of contents Problems encountered during dev...

5 ways to migrate from MySQL to ClickHouse

Data migration needs to be imported from MySQL to...

SystemC environment configuration method under Linux system

The following is the configuration method under c...

JavaScript to achieve fixed sidebar

Use javascript to implement a fixed sidebar, for ...

How to deploy Node.js with Docker

Preface Node will be used as the middle layer in ...

Detailed explanation of the solution to the nginx panic problem

Regarding the nginx panic problem, we first need ...

Summary of tips for making web pages

Preface This article mainly summarizes some of th...

Meta tags in simple terms

The META tag, commonly referred to as the tag, is...

How to get/calculate the offset of a page element using JavaScript

question By clicking a control, a floating layer ...

JavaScript implements front-end countdown effect

This article shares the specific code of JavaScri...

How to completely uninstall Docker Toolbox

Docker Toolbox is a solution for installing Docke...

How to solve the problem of case insensitivity in MySQL queries

question Recently, when I was completing a practi...

Detailed explanation of MySQL batch SQL insert performance optimization

For some systems with large amounts of data, the ...