grant rights on database.* to user@host identified by "pass";

例子:

1:

增加一个test1且密码为abc的用户,让它可以在任何主机上登录,并赋予对所有数据库查询、插入、修改、删除的权限。

mysql> grant select,insert,alter,drop on *.* to test1@"%" identified by "abc";

上图:(我不写没图的博文,有图有真相才是我喜欢的)

2:

增加一个test2且密码为def的用户,让它只能够在localhost主机登录,并对A数据库有select,insert,update,delete权限

 

mysql> grant select,insert,update,delete on A.* to test2@localhost identified by "def";

上图:

注:*.*在批处理中两个星号分别代表任意的文件名和后缀,

在本文代表任意的数据库和其任意的表(包括储存了存储权限的mysql数据库,所以给drop和create权限要谨慎哦)。