What is the easy way to import large database to mysql using phpmyadmin?

前端 未结 4 723
后悔当初
后悔当初 2020-12-21 02:42

I need to import an database(sql file) which is about 120M is size, but in phpmyAdmin, it is not allowed to import more than 8 MB.

How to solve this?

相关标签:
4条回答
  • 2020-12-21 03:23

    if you are sure that the import is clean and doesn't have any duplicates then you could try the following which reduces the time considerably.

    mysql> set autocommit=0; set unique_checks=0; set foreign_key_checks=0;
    mysql> source /path/to/dump.sql
    mysql> commit; set unique_checks=1; set foreign_key_checks=1;
    
    0 讨论(0)
  • 2020-12-21 03:25

    IIRC there is no limit in PHPMyAdmin nor is there in MySQL - the limit is on the POST size (webserver config) or the file upload size (php.ini). If you can't change either of these, then you'll need to upload the file by other means then ....

    mysql -u username -p <mysql_export_file.sql
    

    If you can't upload files / have no shell access / have no CLI version of the mysql client avaialable, then the next thing to try is to see whether you can connect remotely using the mysql CLI client:

    mysql -u username -h www.example.com -p 
    

    If this connects OK, then exit and run it again piping in the exported file

    mysql -u username -h www.example.com -p <mysql_export_file.sql
    

    If that doesn't work then you'll need to either split the export file into multiple smaller chunks or write your own dataloader which trickles the data.

    C.

    0 讨论(0)
  • 2020-12-21 03:40

    I have solved this in three ways in the past, here are the solutions in order of simplicity:

    1) Increase the upload limit. Ask your host to allow you to upload larger files to the server (specifically the post_max_size and upload_max_filesize variables), probably best that they do this in phpMyAdmin's .htaccess file.

    2) Upload via FTP. PHPMyAdmin supports uploading of SQL files via FTP but your host needs to configure the "UploadDir" setting.

    3) Use a different import process. BigDump is the best for this. The problem is that it does still refuses to import some files because of the number of SQL lines or other errors, plus you have to configure it for each site/database.

    0 讨论(0)
  • 2020-12-21 03:44

    I don't have direct access to server, so successfully used BigDump istead. You upload it via FTP together with big SQL file. Then BigDump imports the local file on server, avoiding any HTTP/PHP upload limits.

    0 讨论(0)
提交回复
热议问题