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

Best way to replace the key in json object

JSON (JavaScript Object Notation, JS Object Notat...

Markup validation for doctype

But recently I found that using this method will c...

Example code for implementing dynamic skinning with vue+element

Sometimes the theme of a project cannot satisfy e...

Tutorial on installing MYSQL8.X on Centos

MySQL installation (4, 5, 6 can be omitted) State...

XHTML Getting Started Tutorial: Form Tags

<br />Forms are an important channel for use...

MySQL full-text search Chinese solution and example code

MySQL full text search Chinese solution Recently,...

Practical notes on installing Jenkins with docker-compose

Create a Directory cd /usr/local/docker/ mkdir je...

How to find the specified content of a large file in Linux

Think big and small, then redirect. Sometimes Lin...

Summary of MySQL view principles and usage examples

This article summarizes the principles and usage ...

Differences and comparisons of storage engines in MySQL

MyISAM storage engine MyISAM is based on the ISAM...

Simple implementation method of vue3 source code analysis

Table of contents Preface 🍹Preparation 🍲vue3 usag...

Detailed explanation of the usage of DECIMAL in MySQL data type

Detailed explanation of the usage of DECIMAL in M...

A brief discussion on JavaScript scope

Table of contents 1. Scope 1. Global scope 2. Loc...

Cross-domain issues in front-end and back-end separation of Vue+SpringBoot

In the front-end and back-end separation developm...

Reasons for the sudden drop in MySQL performance

Sometimes you may encounter a situation where a S...