use mysql;
// 修改一条 root 数据,并刷新MySQL的系统权限相关表
update user set Host = '%' where Host = 'localhost' and User = 'root';
flush privileges;
// grant 命令重新创建一个用户
grant all privileges on *.* to root@"%" identified by "root";
添加用户授权(不会覆盖之前的权限)
grant all privileges on *.* to 'username'@'%' identified by '密码' with grant option;
添加权限(和已有权限合并,不会覆盖已有权限)
GRANT Insert ON `your database`.* TO `user`@`host`;
删除权限
REVOKE Delete ON `your database`.* FROM `user`@`host`;
flush privileges;
本文摘自 :https://www.cnblogs.com/