title: NodeJS + MySQL, can't access DB from application while INSERT but can access from terminal
body: <p>I have a big data array which I try to insert into my database, then delete an old table and rename the new one. To do it faster I use TRANSACTION (it doesn't affect my problem, I tried without it) and make every MySQL query inside async.each function. In the callback of this async.each I do COMMIT (for transaction), deleting and renaming.</p>
  
  <p>Usually I have 100000 or more rows to insert. If I use "SELECT COUNT(*)" in terminal I can see these rows insert quite slowly but somehow the process ends immediately when 1/4 of rows was inserted. Then I got a full table in one moment. I don't know why it happens, I'm OK with that but maybe this is the reason of my problem.</p>
  
  <p>So this is my problem: I have no access to DB from Node while it makes inserting. But I still can access it from terminal where I can count rows, see a tables etc. If Node calls some other function with mysql query, this query will just wait until that big insert will end. 
  It's like Node code works in parallel but mysql queries work in just one thread. How can I fix this?</p>
  
  <pre><code>    exports.insertSubscribers = function(data, db_name, done){
          state.pool.query('START TRANSACTION');
          async.each(data, function(row, cb){
              state.pool.query('INSERT INTO new_' + db_name + ' (id, first_name, last_name, sex, city, country, photo_200) VALUES (' + "'" + row.id + "', " + "'" + row.first_name + "', " + "'" + row.last_name + "', " + "'" + row.sex + "', " + "'" + JSON.stringify(row.city) + "', " + "'" + JSON.stringify(row.country) + "', " + "'" + row.photo_200 + "'" + ')', cb);
          }, end_transaction);
  
          function end_transaction(){
              state.pool.query('COMMIT', function(err){
                  if(err) return done(err);
                  state.pool.query('SHOW TABLES LIKE \'' + db_name + '\'', function(err, result){
                      if(result.length != 0){
                          state.pool.query('DROP TABLE ' + db_name, function(err){
                              if(err) return done(err);
                              state.pool.query('RENAME TABLE new_' + db_name + ' TO ' + db_name, function(err){
                                  if(err) return done(err);
                              });
                          });
                      }else{
                          state.pool.query('RENAME TABLE new_' + db_name + ' TO ' + db_name, function(err){
                              if(err) return done(err);
                          });
                      }
                  });
              });
          }
      };
  </code></pre>