Implementation of restoring data by directly copying files in the data directory in mysql

Implementation of restoring data by directly copying files in the data directory in mysql

mysql copies the files in the data directory to restore the data

Background: MySQL crashed and could not be started. I decided to rebuild the environment, but I forgot to back up the database test data. The MySQL data directory survived.

operate:

1. Copy the folder of the test database (including .frm .ibd and other files)

2. Restart MySQL

When viewing a table in the database through Navicat, the result shows "Table 'xxx' does not exist"

3. After searching on Google and Baidu, I found the innodb table

Directly copying the file is not usable, and it will prompt that the table does not exist. When copying, the ibdata1 file in the data directory should be copied together, and the ib_logfile0, ib_logfile1 and other files should be deleted.

mysql migrates the database by copying data files

1. Shut down the service

Run cmd as an administrator and execute the following command:

net stop mysql

2. Copy data files

Copy the database file of the data file (no need to copy mysql, performance_schema, sys), and be sure to copy the ibdata1 file

這里寫圖片描述

3. Import files

Put the copied file into the data file of the destination database

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Springboot uses spring-data-jpa to operate MySQL database
  • DataGrip connects to Mysql and creates a database
  • Springboot configures mysql database spring.datasource.url error solution
  • MySQL database Load Data multiple uses
  • Python pymysql link database query results converted to Dataframe instance
  • MySQL database data basic operations

<<:  Search optimization knowledge to pay attention to in web design

>>:  Three ways to achieve background blur in CSS3 (summary)

Recommend

Install Percona Server+MySQL on CentOS 7

1. Environmental Description (1) CentOS-7-x86_64,...

HTML weight loss Streamline HTML tags to create web pages

HTML 4 HTML (not XHTML), MIME type is text/html, ...

Mysql error: Too many connections solution

MySQL database too many connections This error ob...

Vue uses plug-ins to cut pictures in proportion

This article shares the specific code of Vue usin...

Detailed example code of mysql batch insert loop

background A few days ago, when I was doing pagin...

Common scenarios and avoidance methods for index failure in MySQL

Preface I have read many similar articles before,...

Solution to the error when calling yum in docker container

When executing yum in dockerfile or in the contai...

Building a KVM virtualization platform on CentOS7 (three ways)

KVM stands for Kernel-based Virtual Machine, whic...

Issues installing Python3 and Pip in ubuntu in Docker

text 1) Download the Ubuntu image docker pull ubu...

How to install common components (mysql, redis) in Docker

Docker installs mysql docker search mysql Search ...

Docker installation rocketMQ tutorial (most detailed)

RocketMQ is a distributed, queue-based messaging ...

Complete steps for Docker to pull images

1. Docker pull pulls the image When using $ docke...

Overview of MySQL Statistics

MySQL executes SQL through the process of SQL par...