How to import large sql file in phpmyadmin

前端 未结 20 1310
一向
一向 2020-11-29 17:04

I want to import a sql file of approx 12 mb. But its causing problem while loading. Is there any way to upload it without splitting the sql file ?

相关标签:
20条回答
  • 2020-11-29 17:53

    I dont understand why nobody mention the easiest way....just split the large file with http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/ and after just execute vie mySQL admin the seperated generated files starting from the one with Structure

    0 讨论(0)
  • 2020-11-29 17:53

    PHPmyadmin also accepts compressed files in gzip format, so you can gzip the file (Use 7Zip if you don't have any) and upload the zipped file. Since its a text file, it will have a good compress ratio.

    0 讨论(0)
  • 2020-11-29 17:54

    I have made a PHP script which is designed to import large database dumps which have been generated by phpmyadmin. It's called PETMI and you can download it here [project page] [gitlab page]. It has been tested with a 1GB database.

    0 讨论(0)
  • 2020-11-29 17:55

    3 things you have to do:

    in php.ini of your php installation (note: depending if you want it for CLI, apache, or nginx, find the right php.ini to manipulate)

    post_max_size=500M
    
    upload_max_filesize=500M
    
    memory_limit=900M
    

    or set other values.

    Restart/reload apache if you have apache installed or php-fpm for nginx if you use nginx.

    Remote server?

    increase max_execution_time as well, as it will take time to upload the file.

    NGINX installation?

    you will have to add: client_max_body_size 912M; in /etc/nginx/nginx.conf to the http{...} block

    0 讨论(0)
  • 2020-11-29 17:55

    Ok you use PHPMyAdmin but sometimes the best way is through terminal:

    • Connect to database: mysql -h localhost -u root -p (switch root and localhost for user and database location)
    • Start import from dump: \. /path/to/your/file.sql
    • Go take a coffe and brag about yourself because you use terminal.

    And that's it. Just remember if you are in a remote server, you must upload the .sql file to some folder.

    0 讨论(0)
  • 2020-11-29 17:56

    In MAMP, You could load huge files by :

    1. creating a new folder in this directory /MAMP/bin/phpMyAdmin/"folderName"

    2. and then edit "/MAMP/bin/phpMyAdmin/config.inc.php" line 531 :

         $cfg['UploadDir']= 'folderName';   
      
    3. Copy your .sql or .csv Files into this folder.

    4. Now you will have another option in "PhpMyAdmin" : Select from the web server upload directory newFolder/: You could select your file and import it.

      You could load any file now !!

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