mysql数据库开启远程访问权限,提示无法给用户授权You are not allowed...
问题及解决
(1)首先执行sql语句
grant all privileges on *.* to 'root'@'%';
如果出现报错信息(无法给用户授权):
"You are not allowed to create a user with GRANT"
原因:出现这个问题说明你的数据是8.0以上的。mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,8.0以后已经不支持,所以必须先创建用户,然后再授权
(2)执行sql:
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
(3)重新执行(1)里面的sql语句
(4)此时你可以远程使用ip地址、账号root和密码123456连接测试
如果出现报错信息:
"plugin caching_sha2_password could not be loaded"
尝试修改密码加密插件,执行sql:
alter user 'root'@'%' identified with mysql_native_password by '123456';