mysql>grant all on . to 'user1'@'来源ip地址' identified by '密码'; #定义user1,来源ip 进行登录,所有的库都有权限,或者mysql . 指定一个mysql的库 mysql>grant all on . to 'user1'@'%' identified by '密码'; #%代表所有的ip地址

grant all on . to '用户' identified by '密码'; #grant授权。all代表所有。

grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.133.1' identified by 'passwd'; #针对权限进行授权。SELECT,UPDATE,INSERT 针对db1的库,所有的表给user2,来源ip地址192.168.133.1

grant all on db1.* to 'user3'@'%' identified by 'passwd'; #针对db1的库,所的表给用户user3,ip地址为所有

show grants; #查看当前用户的授权

show grants for user2@192.168.133.1; #查看指定用户的授权。 用户uesr2 来源ip为192.168.133.1。ip地址可以增加。