How can I import a large (14 GB) MySQL dump file into a new MySQL database?

前端 未结 9 1588
醉话见心
醉话见心 2020-11-28 17:45

How can I import a large (14 GB) MySQL dump file into a new MySQL database?

9条回答
  •  感情败类
    2020-11-28 18:04

    I'm posting my finding in a few of the responses I've seen that didn't mention what I ran into, and apprently this would even defeat BigDump, so check it:

    I was trying to load a 500 meg dump via Linux command line and kept getting the "Mysql server has gone away" errors. Settings in my.conf didn't help. What turned out to fix it is...I was doing one big extended insert like:

        insert into table (fields) values (a record, a record, a record, 500 meg of data);
    

    I needed to format the file as separate inserts like this:

        insert into table (fields) values (a record);
        insert into table (fields) values (a record);
        insert into table (fields) values (a record);
        Etc.
    

    And to generate the dump, I used something like this and it worked like a charm:

        SELECT 
            id,
            status,
            email
        FROM contacts
        INTO OUTFILE '/tmp/contacts.sql'
        FIELDS TERMINATED BY ','
        OPTIONALLY ENCLOSED BY '"'
        LINES STARTING BY "INSERT INTO contacts (id,status,email) values ("
        TERMINATED BY ');\n'
    

提交回复
热议问题