MySQL 8.0 以上版本使用下面的命令授权会报错:
mysql> grant all privileges on *.* to root@'%' identified by 'myslag123!@#';
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 ‘myslag123!@#’’ at line 1
因为新版的的mysql版本已经将创建用户和赋予权限的操作分开了,需要分两步操作:
1. 创建用户
mysql> create user 'root'@'%' identified by 'MySlag123!@#';
Query OK, 0 rows affected (0.01 sec)
2. 赋予权限
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)