Importing larger sql files into MySQL

前端 未结 14 2148
感情败类
感情败类 2020-12-12 10:45

I have a 400MB large sql backup file. I\'m trying to import that file into MySQL database using WAMP->import, but the import was unsuccessful due to many reasons such as upl

相关标签:
14条回答
  • 2020-12-12 11:00

    The question is a few months old but for other people looking --

    A simpler way to import a large file is to make a sub directory 'upload' in your folder c:/wamp/apps/phpmyadmin3.5.2 and edit this line in the config.inc.php file in the same directory to include the folder name $cfg['UploadDir'] = 'upload';

    Then place the incoming .sql file in the folder /upload.

    Working from inside the phpmyadmin console, go to the new database and import. You will now see an additional option to upload files from that folder. Chose the correct file and be a little patient. It works.

    If you still get a time out error try adding $cfg['ExecTimeLimit'] = 0; to the same config.inc.php file.

    I have had difficulty importing an .sql file where the user name was root and the password differed from my the root password on my new server. I simply took off the password before I exported the .sql file and the import worked smoothly.

    0 讨论(0)
  • 2020-12-12 11:01

    We have experienced the same issue when moving the sql server in-house.

    A good solution that we ended up using is splitting the sql file into chunks. There are several ways to do that. Use

    http://www.ozerov.de/bigdump/ seems good (but never used it)

    http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/ used it and it was very useful to get structure out of the mess and you can take it from there.

    Hope this helps :)

    0 讨论(0)
  • 2020-12-12 11:01

    On item 1.16 of phpMyAdmin they say:

    1.16 I cannot upload big dump files (memory, HTTP or timeout problems).


    Starting with version 2.7.0, the import engine has been re–written and these problems should not occur. If possible, upgrade your phpMyAdmin to the latest version to take advantage of the new import features.

    The first things to check (or ask your host provider to check) are the values of upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. One user also said that post_max_size and memory_limit need to be larger than upload_max_filesize. There exist several workarounds if your upload is too big or your hosting provider is unwilling to change the settings:

    Look at the $cfg['UploadDir'] feature. This allows one to upload a file to the server via scp, ftp, or your favorite file transfer method. PhpMyAdmin is then able to import the files from the temporary directory. More information is available in the Configuration of this document.

    Using a utility (such as BigDump) to split the files before uploading. We cannot support this or any third party applications, but are aware of users having success with it.

    If you have shell (command line) access, use MySQL to import the files directly. You can do this by issuing the “source” command from within MySQL:

    source filename.sql;
    
    0 讨论(0)
  • 2020-12-12 11:04

    If you are using the source command on Windows remember to use f:/myfolder/mysubfolder/file.sql and not f:\myfolder\mysubfolder\file.sql

    0 讨论(0)
  • 2020-12-12 11:05

    You can make the import command from any SQL query browser using the following command:

    source C:\path\to\file\dump.sql
    

    Run the above code in the query window ... and wait a while :)

    This is more or less equal to the previously stated command line version. The main difference is that it is executed from within MySQL instead. For those using non-standard encodings, this is also safer than using the command line version because of less risk of encoding failures.

    0 讨论(0)
  • 2020-12-12 11:06

    You can import large files this command line way:

    mysql -h yourhostname -u username -p databasename < yoursqlfile.sql
    
    0 讨论(0)
提交回复
热议问题