title: frequent automatic restart of mysql server and later permanent shutdown
body: <p>The MySQL server is restarting frequently. 75 times in less than 24 hours. And finally its ending without restarting!</p>
  
  <p>Please check the details log here: <a href="http://pastebin.com/fLzaj4AJ" rel="nofollow">mysqld.log</a></p>
  
  <pre><code>140113 10:18:22 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
  
  140113 10:18:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  140113 10:18:31  InnoDB: Initializing buffer pool, size = 8.0M
  140113 10:18:31  InnoDB: Completed initialization of buffer pool
  140113 10:18:31  InnoDB: Started; log sequence number 16 1064411530
  140113 10:18:32 [Note] Event Scheduler: Loaded 0 events
  140113 10:18:32 [Note] /usr/libexec/mysqld: ready for connections.
  Version: '5.1.61'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
  
  140113 18:45:09 mysqld_safe Number of processes running now: 0
  140113 18:45:10 mysqld_safe mysqld restarted
  140113 18:45:10  InnoDB: Initializing buffer pool, size = 8.0M
  140113 18:45:10  InnoDB: Completed initialization of buffer pool
  140113 18:45:10  InnoDB: Started; log sequence number 16 1064411530
  140113 18:45:11 [Note] Event Scheduler: Loaded 0 events
  140113 18:45:11 [Note] /usr/libexec/mysqld: ready for connections.
  Version: '5.1.61'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
  </code></pre>
  
  <p>......</p>
  
  <pre><code>140114  9:50:12  InnoDB: Initializing buffer pool, size = 8.0M
  140114  9:50:12  InnoDB: Completed initialization of buffer pool
  140114  9:50:12  InnoDB: Started; log sequence number 16 1064411530
  140114  9:50:13 [Note] Event Scheduler: Loaded 0 events
  140114  9:50:13 [Note] /usr/libexec/mysqld: ready for connections.
  Version: '5.1.61'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
  
  140114 09:55:07 mysqld_safe Number of processes running now: 0
  140114 09:55:07 mysqld_safe mysqld restarted
  140114  9:55:08  InnoDB: Initializing buffer pool, size = 8.0M
  140114  9:55:08  InnoDB: Completed initialization of buffer pool
  140114 09:55:08 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
  </code></pre>
  
  <p>In the meantime its killing 62 processes due to out of memory. Please check the detail log: <a href="http://pastebin.com/yxMFQ82v" rel="nofollow">messages</a></p>
  
  <pre><code>Jan 14 09:41:53 centos63 kernel: Out of memory: Kill process 16795 (mysqld) score 20 or sacrifice child
  Jan 14 09:41:53 centos63 kernel: Killed process 16795, UID 27, (mysqld) total-vm:574508kB, anon-rss:20488kB, file-rss:164kB
  </code></pre>
  
  <p>I am running a cronjob in each 5 minutes which is affecting some tables with about 200000, 50000, 25000 data in three tables.
  SELECT over 1,257 members then over 9,844 member_boards and then INSERT/UPDATE over 168,624 member_cards using the below pseudocode:</p>
  
  <pre><code>&lt;?php
      $qry = _("SELECT _members");
      while($member = mysql_fetch_assoc($res))
      {//1,257
          $qry = _("SELECT _member_boards");
          while($db_board = mysql_fetch_assoc($board_res))
          {//9,844
              $s_lists = curl_download("https://api.com/boards/lists");
              foreach ($lists as $list) {//9,844
                  if(!strcmp('SOMETHING', $list-&gt;name)){//Matching with API and DB
                      $curl = "https://api.com/lists/cards";
                      foreach ($cards as $card) {//168,624
                          $qry = _("SELECT _member_cards");
                          if($card_row = mysql_fetch_assoc($card_res)){
                              $qry = _("UPDATE _member_cards");
                          }
                          else{
                              echo $qry = _("INSERT _member_cards");
                          }
                      }
                  }
              }
  
          }
          $qry = _("UPDATE _member_cards");
      }
  ?&gt;
  </code></pre>
  
  <p>So what can be the reason and how can I solve this issue?</p>
  
  <p>RAM 512 MB until now.</p>
  
  <p>CentOS</p>
  
  <p>Can scaling RAM up to 1 GB solve the issue?</p>