MySQL添加新用户,为新用户分配权限,Mysql版本5.7
首先进入Mysql控制台:
mysql -uroot -p
grant授权格式:grant 权限列表 on 库.表 to 用户名@'ip' identified by "密码";
创建一个新用户(user)并为此用户分配权限(这里先分配对所有数据库的表增删改查的权限),identified by 后面填入你新用户的密码
grant select,insert,update,delete on *.* to 'user'@'%' identified by 'your password';
如果是给予全部权限那么就这样
grant all privileges on *.* to 'user'@'%' identified by 'your password';
记得每次操作完要刷新授权
flush privileges;
查看用户权限
show grants for user;
回收权限,revoke回收权限格式:revoke 权限列表 on 库.表 from 用户名@'ip';
revoke select,insert,update,delete ON *.* from 'user'@'%'