Export a large MySQL table as multiple smaller files

前端 未结 7 1347
你的背包
你的背包 2020-12-28 09:26

I have a very large MySQL table on my local dev server: over 8 million rows of data. I loaded the table successfully using LOAD DATA INFILE.

I now wish to export thi

7条回答
  •  猫巷女王i
    2020-12-28 10:09

    How do I split a large MySQL backup file into multiple files?

    You can use mysql_export_explode https://github.com/barinascode/mysql-export-explode

    db = 'dataBaseName'; # -- Set your database name
    $export->connect('host','user','password'); # -- Connecting to database
    $export->rows = array('Id','firstName','Telephone','Address'); # -- Set which fields you want to export
    $export->exportTable('myTableName',15); # -- Table name and in few fractions you want to split the table
    ?>
    
    At the end of the SQL files are created in the directory where the script is executed in the following format
    ---------------------------------------
    myTableName_0.sql
    myTableName_1.sql
    myTableName_2.sql
    ...
    

提交回复
热议问题