MySQL添加新用户,为新用户分配权限,Mysql版本5.7mysql
首先进入Mysql控制台:sql
mysql -uroot -p数据库
grant受权格式:grant 权限列表 on 库.表 to 用户名@'ip' identified by "密码";ide
建立一个新用户(user)并为此用户分配权限(这里先分配对全部数据库的表增删改查的权限),identified by 后面填入你新用户的密码ip
grant select,insert,update,delete on *.* to 'user'@'%' identified by 'your password';date
若是是给予所有权限那么就这样select
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'@'%'