我使用MySQL已经好几年了,在MySQL 5.x创建新用户的命令如下:; q$ K4 F; v4 o: H% i2 s
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';最近,我安装了它MySQL8.在这种情况下,此命令不起作用。! q3 k5 w, b8 x# K
触发上述命令时,会导致以下错误:3 Z V v1 [% |' J$ _3 O8 Z
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中创建新用户命令的正确语法是什么?* Q" N; u( }4 L$ S# Q5 T9 O
注意:我在MySQL 5.x这种语法在版本中尝试过。它在其中正常工作。* U f3 g* Y# w4 |: ~
! D/ W0 d( r f 解决方案: : [( }# N1 z' b- V4 r d) |, p
试试这个: 1 ?- W2 d, G o# Q% o* e* suse mysql;CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';GRANT ALL ON *.* TO 'username'@'localhost';flush privileges;