grant 权限 on 对象(库.表) to ‘用户名‘@‘主机名‘;
如果是创建用户并授权,可以只需要一条命令执行
grant all on db.tb to ‘username‘@‘localhost‘ identfied by ‘pwd‘;
all 代表所有权限,但是不代表创建的用户有再创建用户,并授权的权限
创建完之后,刷新权限表
flush privileges;
查看用户的权限
show grants for [email protected]‘localhost‘;
mysql> show grants for [email protected]‘localhost‘;
+----------------------------------------------------------------------------+
| Grants for [email protected] |
+----------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO ‘oldboy‘@‘localhost‘ IDENTIFIED BY PASSWORD <secret> |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)
USAGE :如果你创建的用户没有授任何权限就会显示USAGE