MySQL data migration using MySQLdump command

MySQL data migration using MySQLdump command

The advantages of this solution are simplicity and ease of use; the disadvantage is longer downtime. Therefore, it is suitable for situations where the amount of data is not large, or a longer downtime is allowed, and it can be completed within this time frame.

Following are some uses of MySQLdump command:

1. Export the entire database data and table files into a sql file

mysqldump -uroot -proot database1 > database1.sql

2. Import the data of the sql file into mysql instead of mysqldump

mysql -uroot -proot database2 < database1.sql

3. Export the data and structure of a table in the database to a sql file

mysqldump -uroot -proot database1 tablename > table1.sql

4. Import the data of the sql file into mysql instead of mysqldump

mysql -uroot -proot database1 < database1.sql

5. The mysql data migration command backs up the data in the database table whose id is greater than 22. The SQL is as follows

mysqldump -u test -ptest database table --default-character-set=gbk -t --where="id>22" >c:\test.sql

6. Back up the information of students older than 30

mysql> select * from students where Age > 30 into outfile '/tmp/stud.txt'; 
mysql> load data infile '/tmp/stud.txt' into table students;

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Implementing batch processing of MySQL automatic backup under Windows (copying directory or mysqldump backup)
  • Detailed explanation of how to use the mysql backup script mysqldump
  • Detailed explanation of Linux mysqldump exporting database, data, and table structure
  • Detailed discussion on the issue of mysqldump data export
  • A brief discussion on how to use mysqldump (MySQL database backup and recovery)
  • 8 ways to manually and automatically backup your MySQL database
  • Linux implements automatic and scheduled backup of MySQL database every day
  • Detailed explanation of several methods of MySQL automatic backup and recovery (graphic tutorial)
  • How to set up automatic daily backup of mysql in CentOS system
  • Writing daily automatic backup of MySQL database using mysqldump in Centos7

<<:  Mini Program to Implement Sieve Lottery

>>:  How to install binary MySQL on Linux and crack MySQL password

Recommend

Introduction to generating Kubernetes certificates using OpenSSL

Kubernetes supports three types of authentication...

Nginx URL rewriting mechanism principle and usage examples

URL rewriting helps determine the preferred domai...

Solution to running out of MySQL's auto-increment ID (primary key)

There are many types of auto-increment IDs used i...

Automatically build and deploy using Docker+Jenkins

This article introduces Docker+Jenkins automatic ...

MySQL 8.0.15 winx64 installation and configuration method graphic tutorial

This article shares the installation and configur...

MySQL 5.7.12 installation and configuration tutorial under Mac OS 10.11

How to install and configure MySQL on Mac OS 10.1...

Specific use of MySQL global locks and table-level locks

Table of contents Preface Global Lock Table lock ...

Process analysis of deploying ASP.NET Core applications on Linux system Docker

Table of contents 1. System environment 2. Operat...

Summary of 10 amazing tricks of Element-UI

Table of contents el-scrollbar scroll bar el-uplo...

How to restore a single database or table in MySQL and possible pitfalls

Preface: The most commonly used MySQL logical bac...

Vue3 slot usage summary

Table of contents 1. Introduction to v-slot 2. An...