title: MySql - Script to create user and database with hashed password
body: <p>Following the instructions at <a href="https://stackoverflow.com/questions/9529651/mysql-user-creation-script/15969983#15969983">this link</a>, I'm trying to use the following syntax to create an user with a password</p>
  
  <pre><code>DROP DATABASE IF EXISTS forum;
  CREATE DATABASE forum;
  DELETE FROM mysql.user WHERE Host='localhost' AND User='forum_admin';
  #In this way, the password will not be logged in mysql history
  SELECT @password:=PASSWORD('forum_admin');
  GRANT ALL PRIVILEGES ON forum.* TO 'forum_admin'@'localhost' IDENTIFIED BY PASSWORD '@password';
  FLUSH PRIVILEGES;
  </code></pre>
  
  <p>However, the penultimate instruction gives this error</p>
  
  <pre><code>ERROR 1827 (HY000): The password hash doesn't have the expected format. Check if the correct password algorithm is being used with the PASSWORD() function.
  </code></pre>
  
  <p>So, how can I solve? I don't want to manually insert the result of the <code>SELECT @password</code> (as explained <a href="https://stackoverflow.com/a/9529919/2326627">here</a> or <a href="https://stackoverflow.com/a/15969983/2326627">here</a> for example), but I'd like to use those result to create automatically a new user.</p>