corresponds to your MySQL server version for the right syntax to use near ‘identified by “解决办法

报错:

mysql> grant all privileges on *.* to "root"@"%" identified by "xxxxx";

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 xxxxx

查看数据库版本,高版本数据库不能按照grant all privileges on *.* to "root"@"%" identified by "xxxx";去修改用户权限

mysql> SELECT @@VERSION;
+-----------+
| @@VERSION |
+-----------+
| 8.0.15    |
+-----------+
1 row in set (0.00 sec)

分布执行:

mysql> create user 'root'@'%' identified by  'password';
Query OK, 0 rows affected (0.03 sec)

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

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

再次查看发现有了root % 

mysql>  select User,Host from user;
+------------------+-----------+
| User             | Host      |
+------------------+-----------+
| root             | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

验证 

 

猜你喜欢

转载自blog.csdn.net/qq_38376348/article/details/107670766