Home  >  Article  >  Database  >  How to Split Large Mysqldump Outputs into Smaller Importable Files?

How to Split Large Mysqldump Outputs into Smaller Importable Files?

DDD
DDDOriginal
2024-11-15 06:21:02570browse

How to Split Large Mysqldump Outputs into Smaller Importable Files?

Splitting Mysqldump Output into Smaller Files

In situations where one needs to transfer large database tables between MySQL databases with restricted upload limits, the mysqldump output may exceed the allowable file size. To address this issue, splitting the dump file into smaller, importable chunks is a viable solution.

One popular approach is to utilize a Bash script that divides the dump file based on table boundaries. The script performs the following steps:

  1. Extract Tables: Using the csplit command, the script separates each table into individual files denoted by their respective names.
  2. Head and Foot Truncation: A "head" file is created containing the initial portion of the dump file before the first table, and a "foot" file contains the ending portion after the last table.
  3. Concatenation: For each extracted table file, the head, table contents, and foot are concatenated to create complete SQL files for each table.
  4. Clean Up: The script removes the temporary files generated during the splitting process.

By following these steps, you can effectively split a large mysqldump output into smaller, importable files, allowing you to transfer large tables between databases with limited file size restrictions.

The above is the detailed content of How to Split Large Mysqldump Outputs into Smaller Importable Files?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn