1. 更改加密权限和用户密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; #mysql_native_password规则加密
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER; #更新一下用户的密码
UPDATE user SET host = '%' WHERE user = 'root'; #允许远程访问
flush privileges; #刷新权限
2. 创建用户
CREATE USER '创建的用户名'@'%' IDENTIFIED BY '用户密码'; # %表示该用户能远程连接mysql
3. 赋予用户权限
grant all privileges on *.* to '创建的用户名'@'%' ; # localhost表示该用户只能通过本地连接到mysql且永久生效不可更改
flush privileges; #刷新权限