我正在尝试按照此链接中的说明,使用以下语法创建带密码的用户
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;
然而,倒数第二条指令出现了错误。
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.
那么,我该如何解决呢?我不想手动插入SELECT @password
的结果(例如在这里或这里解释过),但我希望使用这些结果自动创建一个新用户。
GRANT ALL [PRIVILEGES]
一样,但事实并非如此。它似乎只是在提供的字符串上调用password
函数。https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_password - Elvin