MySQL 添加新用户,为新用户分配权限,Mysql 版本 5.7
mysql-5.7.28-winx64
首先进入 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'@'%'
链接:https://pan.baidu.com/s/1bp6vohHPNykiRDeQjzi7jg
提取码:jie7