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

What is ssh port forwarding? What's the use?

Table of contents Preface 1. Local port forwardin...

Some data processing methods that may be commonly used in JS

Table of contents DOM processing Arrays method Su...

Linux five-step build kernel tree

Table of contents 0. The kernel tree that comes w...

Detailed steps for quick installation of openshift

The fastest way to experience the latest version ...

Basic tutorial on controlling Turtlebot3 mobile robot with ROS

Chinese Tutorial https://www.ncnynl.com/category/...

Implementation of Vue top tags browsing history

Table of contents nonsense Functions implemented ...

How to regularly clean up docker private server images

Using CI to build docker images for release has g...

MariaDB under Linux starts with the root user (recommended)

Recently, due to the need to test security produc...

MySQL optimization query_cache_limit parameter description

query_cache_limit query_cache_limit specifies the...

Perfect solution to Docker Alpine image time zone problem

Recently, when I was using Docker to deploy a Jav...

MySQL case when group by example

A mysql-like php switch case statement. select xx...

Implementation of vue3.0+vant3.0 rapid project construction

Table of contents 1. Project Construction 2. Vue3...