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

How to deploy Tencent Cloud Server from scratch

Since this is my first post, if there are any mis...

Tips on making web pages for mobile phones

Considering that many people now use smartphones, ...

How to install phabricator using Docker

I am using the Ubuntu 16.04 system here. Installa...

How to display small icons in the browser title bar of HTML webpage

Just like this effect, the method is also very si...

Analysis of MySQL latency issues and data flushing strategy process

Table of contents 1. MySQL replication process 2....

React implements import and export of Excel files

Table of contents Presentation Layer Business Lay...

Let you understand the working principle of JavaScript

Table of contents Browser kernel JavaScript Engin...

MySQL table return causes index invalidation case explanation

Introduction When the MySQL InnoDB engine queries...

Use momentJs to make a countdown component (example code)

Today I'd like to introduce a countdown made ...

MySQL foreign key constraint (FOREIGN KEY) case explanation

MySQL foreign key constraint (FOREIGN KEY) is a s...

Beginners learn some HTML tags (2)

Related article: Beginners learn some HTML tags (1...

A detailed explanation of the subtle differences between Readonly and Disabled

Readonly and Disabled both prevent users from chan...

What we can learn from Google's new UI (pictures and text)

The most significant website change in 2011 was Go...