我使用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 1MySQL 8中的语法有什么变化吗?在MySQL 8中创建新用户命令的正确语法是什么?
注意:我在MySQL 5.x版本中尝试过这种语法。它在这一点上工作正常。
发布于 2018-05-18 23:11:26
试试这个:
use mysql;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'localhost';
flush privileges;发布于 2021-08-01 14:40:31
从MySQL最新版本-
要创建用户-
CREATE USER 'newuser1'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password@123';
GRANT ALL ON *.* TO 'newuser1'@'localhost';这是两行代码,用于创建新用户和授予权限。
使用MySQL社区服务器版本8.0.26 windows 10 x64位服务器。
https://stackoverflow.com/questions/50409788
复制相似问题