MySQL8和MySQL5.x创建账号不太一样,MySQL8不允许用grant创建新用户,要先创建账号再设置权限
# 创建用户
create user ‘root‘@‘%‘ identified by ‘1‘;
# 授权 grant all privileges on *.* to ‘root‘@‘%‘ with grant option;
# 刷新权限 flush privileges; # 修改密码加密方式(MySQL8默认用caching_sha2_password插件加密) alter user root identified with mysql_native_password by ‘xxx‘;