title: How to disable triggers in MySQL?
body: <p>In my MySQL database I have some triggers <code>ON DELETE</code> and <code>ON INSERT</code>. Sometimes I need to disable some triggers, and I have to <code>DROP</code> e.g.</p>
  
  <pre><code>DROP TRIGGER IF EXISTS hostgroup_before_insert //   
  </code></pre>
  
  <p>and reinstall. Is there any shortcut to <code>SET triggers hostgroup_before_insert = 0</code> like we have for foreign keys:</p>
  
  <pre><code>mysql&gt; SELECT version();
  +-------------------------+
  | version()               |
  +-------------------------+
  | 5.1.61-0ubuntu0.10.10.1 |
  +-------------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p><strong>EDIT</strong> Answer
  There is <strong>no built-in server system variable TRIGGER_CHECKS in MySQL</strong>.<br>
  A simple workaround is to instead use a user-defined session variable.     </p>
  
  <pre><code>#FALSE value overrides trigger type settings
  SET @TRIGGER_CHECKS = [TRUE|FALSE]; 
  
  SET @TRIGGER_BEFORE_INSERT_CHECKS = [TRUE|FALSE];
  SET @TRIGGER_AFTER_INSERT_CHECKS = [TRUE|FALSE];
  
  DELIMITER $$
  DROP TRIGGER IF EXISTS `yearCheck_beforeInsert` $$
  CREATE DEFINER=`root`@`localhost` TRIGGER `yearCheck_beforeInsert`
  BEFORE INSERT ON `movies` FOR EACH ROW 
  
  #Patch starts here
  thisTrigger: BEGIN
    IF ((@TRIGGER_CHECKS = FALSE)
        OR (@TRIGGER_BEFORE_INSERT_CHECKS = FALSE))
      AND (USER() = 'root@localhost') 
  </code></pre>
  
  <p>This <a href="http://mysql-0v34c10ck.blogspot.in/2011/06/how-to-disableenable-triggers-on-demand.html" rel="noreferrer"><strong>TRICK is Explained here</strong></a>.</p>