如何在MySQL 8.0中为root用户授予所有访问权限?

雪花 发表于: 2019-11-14   最后更新时间: 2019-11-14 19:04:10   2,868 游览

我使用

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

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 ‘root’ WITH GRANT OPTIONat line 1.

也试过了

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

ERROR 1410 (42000): You are not allowed to create a user with GRANT
MySQL(8.0.11.0)用户名/密码是 root/root.
发表于 2019-11-14
添加评论

从 MySQL 8 开始,不可以(隐式)使用GRANT命令创建用户。改用CREATE USER,然后再使用GRANT声明:

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
你的答案

查看mysql相关的其他问题或提一个您自己的问题