title: How to insert a very large number of records into a MySql database as fast as possible
body: <p>I have a database table like below:</p>
  
  <pre><code>create table temperature
  (id int unsigned not null auto_increment primary key,
  temperature double
  );
  </code></pre>
  
  <p>And in my program I got about 20 million temperature to insert into the table.
  I worke in .Net environment, use Connector/Net connecting to MySql. The code was like below:</p>
  
  <pre><code>List&lt;double&gt; temps = new List&lt;double&gt;();
  ...
  string connStr = "server=localhost;user=name;database=test;port=3306;password=*****;";
  MySqlConnection conn = new MySqlConnection(connStr);
  try
  {
      conn.Open();
  
      //temps.Count is about 20 million
      for (int i = 0; i &lt; temps.Count; i++)
      {
          string sql1 = "INSERT INTO temperature VALUES (null, "+temps[i]+")";
          MySqlCommand cmd1 = new MySqlCommand(sql1, conn);
          cmd1.ExecuteNonQuery();
      }
  
  }
  catch (Exception ex)
  {
      Console.WriteLine(ex.ToString());
  }
  conn.Close();
  </code></pre>
  
  <p>How can i insert so many lines data as fast as possible?
  (It can only insert 2000 records every minute in my computer.)</p>