title: Drop procedure if exists in mysql
body: <p>Hi i am trying to create a mysql script that I can run whenever I need to update my database. The script creates a table and then executes some stored procedures. </p>
  
  <pre><code>DELIMITER $$
  
  CREATE TABLE IF NOT EXISTS tbl_name (
      col1 bigint(20) NOT NULL AUTO_INCREMENT,
      col2  varchar(255) NOT NULL,
      col3 varchar(64) NOT NULL,
      col4 datetime DEFAULT NULL,
      PRIMARY KEY (`col1 `),
      UNIQUE KEY col2  (`col2`)
  ) ENGINE=InnoDB AUTO_INCREMENT=572 DEFAULT CHARSET=utf8$$
  
  CREATE DEFINER=`root`@`localhost` PROCEDURE `myproc`(IN username 
  VARCHAR(255))
  BEGIN
      DECLARE var1 VARCHAR(64);
      DECLARE expirationDate DATETIME;
  
      SET var1 = 12345;
      SET expirationDate = DATE_ADD(NOW(), INTERVAL 30 SECOND);
  
      REPLACE INTO tbl_name (col2, col3, col4) VALUES (someval, var1, expirationDate);
  END$$
  
  DELIMITER ;
  </code></pre>
  
  <p>When I ran the script first time, it created the table and executed the stored procedure in MySQL Workbench. When I ran the same thing second time, I got the error 1304 procedure already exists. </p>
  
  <p>I looked online <a href="https://dev.mysql.com/doc/refman/5.7/en/replication-features-drop-if-exists.html" rel="noreferrer">here</a> about dropping the procedure and then create again. But when I entered the below command before creating the procedure, i got an error on <code>CREATE</code> command with code 1064.  </p>
  
  <pre><code>DROP PROCEDURE IF EXISTS myproc;
  CREATE DEFINER=`root`@`localhost` PROCEDURE `myproc`(IN username 
      VARCHAR(255))
  .
  .
  .
  </code></pre>
  
  <p>I am very new to mysql and not sure how to execute the procedure if it already exists. </p>
  
  <p>Any help would be appreciated. </p>