MySQL8.0 :grant all privileges on *.* to 报错问题

报了这个错误

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 ‘你的密码’’ at line 1

提示意思是不能用grant创建用户,mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,mysql8.0以后已经不支持,所以必须先创建用户,然后再授权,命令如下

mysql> CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';
Query OK, 0 rows affected (0.48 sec)

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.48 sec)

你可能感兴趣的:(mysql,数据库)