关于解决mysql数据库设置远程连接权限执行grant all privileges on *.* to 'root'@'%' identified by '密码' with grant optio报错的问题
在CentOS7下使用mysql设置远程连接权限时,使用以下语句会显示数据语法错误
grant
all
privileges
on
*.*
to
‘root‘@‘%‘ identified
by
‘123456‘
with
grant
opti
原因:mysql的版本问题,这条语句适用于MySQL8.0之前
解决: mysql8.0及以上版本需要使用以下语句:
1
2
create
user
root@
'%'
identified
by
'123456'
;
grant
all
privileges
on
*.*
to
root@
'%'
with
grant
option
;
小心语句中的引号导致出现中文字符的问题,建议手写代码运行