mysql8 grant授权报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT

问题说明:

  1. 在8.0以前,我们习惯使用以下命令授权远程连接操作:
grant all privileges on *.* to 'root'@'%';
  1. 但在8.0以后,使用以上命令会报错:
ERROR 1410 (42000): You are not allowed to create a user with GRANT

分析原因:

因为在8.0以后,这个特性已被移除,官方文档如下:

原文:Using GRANT to modify account properties other than privilege assignments. This includes
authentication, SSL, and resource-limit properties. Instead, establish such properties at account-creation
time with CREATE USER or modify them afterward with ALTER USER.
译文:使用grant修改账户权限分配以外的账户属性。包括认证,SSL,和资源限制配置等。取而代之的是创建用户create user或者创建后修改alter user的方式。

解决方案:

  1. 使用以下命令可以成功,但无法远程登陆:
grant all on *.* to 'root'@'localhost';
  1. 此时,可以使用以下2种方式,实现远程:
-- 1. 使用update user
update user set host='%' where user ='root';
-- 2. 使用create user
create user 'userName'@'%' identified by 'your_password';
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容