title: dovecot password hashing with mysql 8 SHA2
body: <p>Previously (MySQL 5.7) we was using this command to add a new email address into an existing table:</p>
  
  <pre><code>INSERT INTO `servermail`.`virtual_users`
  (`id`, `domain_id`, `password` , `email`)
  VALUES
  ('1', '1', ENCRYPT('password', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'user@example.com'),
  </code></pre>
  
  <p>then dovecot was able to authenticate users. (<a href="https://wiki2.dovecot.org/Authentication/PasswordSchemes" rel="noreferrer">more information</a> about dovecot password scheme)<br>
  Now Encrypt has been deprecated in the recent versions of MySQL. (<a href="https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_encrypt" rel="noreferrer">link</a>)</p>
  
  <p>I want to rewrite that command using SHA2 but I wasn't succeed.</p>
  
  <p><strong>Edit:</strong><br>
  This could help someone to use <a href="https://www.digitalocean.com/community/tutorials/how-to-configure-a-mail-server-using-postfix-dovecot-mysql-and-spamassassin" rel="noreferrer">How To Configure a Mail Server Using Postfix, Dovecot, MySQL, and SpamAssassin</a> to configure a Mail Server with version 8.0 of Mysql.</p>