MySQL8.0给root用户赋予远程连接权限

1 问题引入:直接使用“grant all privileges on *.* to 'root'@'%' with grant option;”给root用户赋予可远程连接权限时报

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 '123456' WITH GRANT OPTION' at line 1 错误

2 解决方案

use mysql;/*选中mysql数据库*/

update user set host='%' where user ='root';/*修改库中user表中,user用户的host=%(任意连接)*/

flush privileges;/*重新加载权限表*/

grant all privileges on *.* to 'root'@'%' with grant option;/*给root用户赋予远程连接权限*/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。