How to import large sql file in phpmyadmin

前端 未结 20 1308
一向
一向 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:42

    Edit the config.inc.php file located in the phpmyadmin directory. In my case it is located at C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php.

    Find the line with $cfg['UploadDir'] on it and update it to $cfg['UploadDir'] = 'upload';

    Then, create a directory called ‘upload’ within the phpmyadmin directory (for me, at C:\wamp\apps\phpmyadmin3.2.0.1\upload\).

    Then place the large SQL file that you are trying to import into the new upload directory. Now when you go onto the db import page within phpmyadmin console you will notice a drop down present that wasn’t there before – it contains all of the sql files in the upload directory that you have just created. You can now select this and begin the import.

    If you’re not using WAMP on Windows, then I’m sure you’ll be able to adapt this to your environment without too much trouble.

    Reference : http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/comment-page-4/

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

    Best way to upload a large file not use phpmyadmin . cause phpmyadin at first upload the file using php upload class then execute sql that cause most of the time its time out happened.

    best way is : enter wamp folder>bin>mysql>bin dirrectory then write this line

    mysql -u root -p listnames < latestdb.sql here listnames is the database name at first please create the empty database and the latestdb.sql is your sql file name where your data present .

    but one important thing is if your database file has unicode data . you must need to open your latestdb.sql file and one line before any line . the line is :

    SET NAMES utf8; then your command mode run this script code

    0 讨论(0)
  • 2020-11-29 17:44
    1. Open your sql file in a text editor (like Notepad)
    2. Select All -> Copy
    3. Go to phpMyAdmin, select your database and go to SQL tab
    4. Paste the content you have copied in clipboard
    5. It might popup a javascript error, ignore it
    6. Execute
    0 讨论(0)
  • 2020-11-29 17:47

    Just one line and you are done (make sure mysql command is available as global or just go to mysql installation folder and enter into bin folder)

    mysql -u database_user_name -p -D database_name < complete_file_path_with_file_name_and_extension 
    

    Here

    • u stands for User
    • p stands for Password
    • D stands for Database

    ---DON'T FORGET TO ADD < SIGN AFTER DATABASE NAME---

    Complete file path with name and extension can be like

    c:\folder_name\"folder name"\sql_file.sql

    ---IF YOUR FOLDER AND FILE NAME CONTAINS SPACE THAN BIND THEM USING DOUBLE QUOTE---

    Tip and Note: You can write your password after -p but this is not recommended because it will show to others who are watching your screen at that time, if you don't write there it will ask you when you will execute command by pressing enter.

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

    Solution for LINUX USERS (run with sudo)

    Create 'upload' and 'save' directories:

    mkdir /etc/phpmyadmin/upload
    mkdir /etc/phpmyadmin/save
    chmod a+w /etc/phpmyadmin/upload
    chmod a+w /etc/phpmyadmin/save
    

    Then edit phpmyadmin's config file:

    gedit /etc/phpmyadmin/config.inc.php
    

    Finally add absolute path for both 'upload' and 'save' directories:

    $cfg['UploadDir'] = '/etc/phpmyadmin/upload';
    $cfg['SaveDir'] = '/etc/phpmyadmin/save';
    

    Now, just drop files on /etc/phpmyadmin/upload folder and then you'll be able to select them from phpmyadmin.

    Hope this help.

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

    the answer for those with shared hosting. Best to use this little script which I just used to import a 300mb DB file to my server. The script is called Big Dump.

    provides a script to import large DB's on resource-limited servers

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