title: mysql create user if not exists
body: <p>I have a query to check mysql users list for create new user.</p>
  
  <pre><code>IF (SELECT EXISTS(SELECT 1 FROM `mysql`.`user` WHERE `user` = '{{ title }}')) = 0 THEN
      CREATE USER '{{ title }}'@'localhost' IDENTIFIED BY '{{ password }}'
  END IF;
  </code></pre>
  
  <p>But i get this error:</p>
  
  <pre><code>ERROR 1064 (42000) at line 3: 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 'IF (SELECT EXISTS(SELECT 1 FROM `mysql`.`user` WHERE `user` = 'cms_localhost')) = 0 ' at line 1
  </code></pre>