Pages

PHPMYADMIN: upload 1.5 gb file in phpmyadmin

Uploading a 1.5 GB file in phpMyAdmin can be challenging due to default size limitations in PHP and MySQL. However, you can increase these limits and successfully import the file by following these steps:


1. Increase PHP Configuration Limits

Modify the PHP configuration file (php.ini) to allow larger uploads.

  1. Open your php.ini file (its location depends on your server setup, often in /etc/php/ or C:\xampp\php\ for XAMPP).
  2. Update the following values:
    upload_max_filesize = 2G
    post_max_size = 2G
    max_execution_time = 300
    max_input_time = 300
    memory_limit = 2G
    
  3. Restart your web server (Apache/Nginx) to apply the changes.

2. Adjust phpMyAdmin Configurations

You can configure phpMyAdmin's config.inc.php file to handle large imports.

  1. Locate the config.inc.php file in the phpMyAdmin directory.
  2. Add or modify the following settings:
    $cfg['ExecTimeLimit'] = 300;
    $cfg['MaxFileSize'] = '2048M';
    $cfg['UploadDir'] = '';
    

3. Use the Command-Line Interface

For very large files, using the MySQL command-line tool is more reliable.

  1. Open the terminal or command prompt.
  2. Run the following command:
    mysql -u username -p database_name < /path/to/your/file.sql
    
    Replace username, database_name, and /path/to/your/file.sql with your actual MySQL username, database name, and file path.

4. Split the File (If Necessary)

If the file is still too large, split it into smaller chunks using a tool like SQLDumpSplitter or split in Linux:

  • On Linux:

    split -l 50000 large_file.sql small_file_
    

    This splits the file into chunks of 50,000 lines each.

  • Import each chunk individually in phpMyAdmin or via the command line.


5. Uploading Through phpMyAdmin

Once the limits are increased:

  1. Go to phpMyAdmin.
  2. Select the database.
  3. Use the Import tab to upload your .sql file.

By following these steps, you should be able to upload your 1.5 GB file successfully.

No comments:

Post a Comment