#授权用户
mysql> grant all privileges on *.* to test@'10.10.10.%' identified by 'test123'; #允许test用户远程从10.10.10.0/24上连接,所有数据库全部权限
mysql> grant privileges on db1.tablename to [email protected] identified by "password"; #指定数据库授所有权限
mysql> grant select,insert on *.* to test@'10.10.10.%' identified by 'test123'; #授予select和insert权限,用户只能从10.10.10.0/24连接
mysql> grant all privileges on *.* to test@localhost; #授予全部权限,只能localhost登录
mysql> grant select,insert,update,delete,create temporary tables,execute,show view on `db1`.* to 'user1'@'10.168.0.8'; # 按数据库授特定权限
#查看用户
mysql> grant all privileges on test.* to test@localhost; #授予全部权限,只能localhost登录
mysql> select user(); #查看当前连接用户
mysql> show grants for 'user'@'ip' #查看用户权限
mysql> select User from mysql.user where User="test" \G; #查看用户权限
#删除或者取消用户权限
mysql> revoke select,insert,update,delete,create temporary tables,execute,show view on `db1`.* from 'user1'@'10.168.0.8'; # 按数据库取消特定权限
mysql> drop user 'user1'@'10.168.0.8'; # 删除特定的用户
mysql> flush privileges; # 刷新权限