title: Import large file on MySQL DB
body: <p>I want to insert about 50,000 mysql query for 'insert' in mysql db,
  for this i have 2 options, </p>
  
  <p>1- Directly import the (.sql) file:
  Following error is occur 
  " You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit. "</p>
  
  <p>2- Use php code to insert these queries in form of different chunks from the (.sql) file.
  here is my code:</p>
  
  <pre><code>&lt;?php
  
  // Configure DB
  include "config.php";
  
  // Get file data
  $file = file('country.txt'); 
  
  // Set pointers &amp; position variables
  $position = 0;
  $eof = 0; 
  
  while ($eof &lt; sizeof($file))
  {
      for ($i = $position; $i &lt; ($position + 2); $i++)
      {
          if ($i &lt; sizeof($file))
          {
              $flag = mysql_query($file[$i]);
  
              if (isset($flag))
              {
                  echo "Insert Successfully&lt;br /&gt;";
                  $position++;
              }
  
              else
              {
                  echo mysql_error() . "&lt;br&gt;\n";
              }
          }
  
          else
          {
              echo "&lt;br /&gt;End of File";
              break;
          }
      }
  
      $eof++;
  }
  
  ?&gt;
  </code></pre>
  
  <p>But memory size error is occur however i have extend memory limit from 128M to 256M or even 512M.</p>
  
  <p>Then i think that if i could be able to load a limited rows from (.sql) file like 1000 at a time and execute mysql query then it may be import all records from file to db.
  But here i dont have any idea for how to handle file start location to end and how can i update the start and end location, so that it will not fetch the previously fetched rows from .sql file.</p>