解决mysql8 提示 ERROR 1064 (42000): You are not allowed to create a user with GRANT

今天为创建的root 用户授予相关权限提示如下错误:

mysql> grant all privileges on test.* to root@'%' identified '123456';

提示如下错误:ERROR 1064(4200): you have an error in you SQL syntax; **near ‘identified ‘123456’’ at line 1
查询MySQL8 相关授权资料的得知,分配权限不能带密码。

修改后的指令如下:

mysql >  grant all privileges on test.* to root@'%'

提示的错误信息如下:You are not allowed to create a user with GRANT;
产生用户不能授权的原因是mysql 数据库中user 表中的特定用户(root) 的host 的属性值为localhost.

解决办法如下:

# 使用mysql 数据库
mysql > use mysql;
# 特定用户的host 修改
mysql > update user set host='%' where user='root';
# 指定用户的授权
mysql > grant all privileges on test.* to root@'%'
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐