作者:S里覀格J | 来源:互联网 | 2022-12-16 20:14
我使用MySQL已有好几年了,创建新用户的命令直到MySQL 5.x版本如下:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
最近我安装了MySQL 8.在那,这个命令不起作用.
在触发上述命令时抛出以下错误:
ERROR 1064 (42000): 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 'IDENTIFIED BY 'password'' at line 1
MySQL 8中的语法有什么变化吗?在MySQL 8中创建新用户命令的正确语法是什么?
注意:我在MySQL 5.x版本中尝试了这种语法.它正常工作.
1> 小智..:
试试这个:
use mysql;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'localhost';
flush privileges;