MySQL权限管理

查看用户
mysql> select host,user,password from mysql.user;

创建用户
mysql> create user z_root IDENTIFIED by '123456'; 

修改用户
mysql> rename user z_root to x_root;

更改密码
mysql>  set password for z_root = password('12345678');

删除用户
mysql>  drop user z_root;

查看用户权限
mysql> show grants for z_root;

赋予权限
mysql> grant select on db_name.* to z_root;
mysql> grant drop on db_name.* to z_root@'192.168.0.%';

回收权限
mysql> revoke select,update,delete,insert on db_name.* from z_root;
mysql> revoke all on db_name.* from z_root;

刷新
mysql>  flush  privileges;



添加用户并绑定数据库和IP流程:
mysql>  grant all on databaseName.* to 'new_user'@'127.0.0.2' IDENTIFIED by '123456';
mysql>  flush  privileges;
mysql>  select host,user,password from mysql.user;   #查看用户
mysql>  drop user 'new_user'@'127.0.0.2';   #删除刚创建的用户



你可能感兴趣的:(MySQL权限管理)