mysql implements importing only a specified table from the sql file of exported data

mysql implements importing only a specified table from the sql file of exported data

Scenario

Yesterday the system automatically backed up all table data of a certain database, named dbAll.sql.gz. The file is large (e.g. 40G)

Today, we found a problem with a piece of data in tableA, and we need to check the changes of two records. The data of tableA needs to be retrieved from dbAll in order to compare the record.

Operational Scheme

1. Import dbAll.sql.gz into the database to be compared (temporary database), and then compare tableA. Not recommended because the amount of data is too large and it is time-consuming

2. After decompressing dbAll.sql.gz, use Java code to read the CREATE statements and INSERT statements about tableA in dbAll.sql into the file tableA.sql, and then import tableA.sql into the temporary database for comparison.

3. See (not tried): mysqldump exports the entire database alldb.sql. Can I only import one table when importing?

Method 1:

perl extract_sql.pl -t mytable -r mydumpfile > mytable.sql

Method 2:

cat test1db.sql | sed -n '/Table structure for table .test1./,/Table structure for table .test2./p'>/tmp/xxx.sql

Method 3:

awk '/Table structure for table .test1./,/Table structure for table .test2./{print}' src_bake_db.sql.gz > targetdb.sql

Method 3: Export the data of the test1 and test2 tables in the src_bake_db.sql.gz compressed file to targetdb.sql

Supplementary knowledge: The mysql command line exports the first 100 records of all tables in the entire database

As shown below:

mysqldump -uysp -pYspxxx db_name --where="1=1 limit 100" >/mnt/share/paxxx.com/backup.sql

Just run it directly on the command line without logging into the mysql client.

mysqldump -h server name -u account name -p database name --where="true limit 100"> /tmp/supports_launch.sql

phpmyadmin export php script:

http://local.phpmyadmin.com/export.php

The above MySQL implementation of importing only a specified table from the sql file of exported data is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of using mysqldump to export data from MySQL database
  • How to use mysqldump to backup and restore specified tables
  • Mysql command line import sql data
  • Detailed explanation of mysqldump backup and restore and mysqldump import and export statements

<<:  Vue implements small form validation function

>>:  Detailed explanation of the Docker deployment tutorial for Jenkins beginners

Recommend

Detailed tutorial on uploading and configuring jdk and tomcat on linux

Preparation 1. Start the virtual machine 2. git t...

MySQL scheduled backup solution (using Linux crontab)

Preface Although some love in this world has a pr...

Three ways to implement waterfall flow layout

Preface When I was browsing Xianyu today, I notic...

Summary of knowledge points on using calculated properties in Vue

Computed properties Sometimes we put too much log...

Detailed explanation of the process of using docker to build minio and java sdk

Table of contents 1minio is simple 2 Docker build...

VUE Getting Started Learning Event Handling

Table of contents 1. Function Binding 2. With par...

jQuery implements navigation bar effect with expansion animation

I designed and customized a navigation bar with a...

MySQL series tutorials for beginners

Table of contents 1. Basic concepts and basic com...

Solution to large line spacing (5 pixels more in IE)

Copy code The code is as follows: li {width:300px...

Several ways of running in the background of Linux (summary)

1. nohup Run the program in a way that ignores th...

Detailed tutorial on deploying Jenkins based on docker

0. When I made this document, it was around Decem...

js memory leak scenarios, how to monitor and analyze them in detail

Table of contents Preface What situations can cau...

How to use firewall iptables strategy to forward ports on Linux servers

Forwarding between two different servers Enable p...