title: create mysql trigger in shell command line
body: <p>I need to create a mysql trigger in command line</p>
  
  <p>This sql working good in mysql console:</p>
  
  <pre><code>$sql = "
      USE DB1;
      DROP TRIGGER IF EXISTS my_trigger;
      DELIMITER $$
      CREATE TRIGGER my_trigger AFTER UPDATE ON tbl1
       FOR EACH ROW BEGIN 
          INSERT INTO DB2.tbl2 (column1)
          VALUES (1234);
      END$$
      DELIMITER ;
  ";
  
  $cmd = 'mysql -sse "'.$sql.'";';
  
  //put all in one line to avoid shell errors
  $cmd = preg_replace('/\r\n|\r|\n|\t|\s+/m', " ", $cmd);
  
  exec("($cmd) 2&gt;&amp;1", $output, $result);
  </code></pre>
  
  <p>This thrown an mysql error</p>
  
  <blockquote>
    <p>ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
    check the manual that corresponds to your MySQL server version for the
    right syntax to use near \'END\' at line 1</p>
  </blockquote>
  
  <p>I have also tried with <code>DELIMITER //</code> ... same error</p>