mysql为远程用户授权及撤销授权

1. mysql 查看用户

mysql> select User,Host,Password from mysql.user;


2. mysql修改密码

mysql> update mysql.user set password=password("Anonymous") where user="root" and host="localhost";(设置新密码)

mysql> flush privileges;(刷新)


3. MySQL为root授予远程登陆权限

 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'MyPassword' WITH GRANT OPTION;


4. 查看存储类型

show varibales like 'storage_engine%';


5. 查看新建表的详细信息

mysql> show create table IT_salary;


6. 查看授权用户的权限信息

格式:

show grants for 用户名@"客户端地址";

mysql> show grants for hydra@"192.168.4.%";

命令格式:

grant 权限列表 on 数据库名 to 用户名;

grant 权限列表 on 数据库名 to 用户名;(指定的地址才可以链接)

grant 权限列表 on 数据库名 to 用户名@客户端地址 identified by "密码";(指定的地址,且输入密码才可以链接)

grant 权限列表 on 数据库名 to 用户名@客户端地址 identified by "密码" with grant option;(授权的用户,可以给其他用户授权)

示例:

grant all on *.* to [email protected];

grant select on userinfo.* to [email protected] identified by "123456" with grant option;

grant select,insert,update(name) on studb.t1 to hydra;


7. 撤销用户权限

格式:

revoke 权限列表 on 数据库名 from 用户@"客户端地址";

实例:mysql> revoke insert on userinfo.t1 from hydra@"192.168.4.254";

撤销用户授权权限:(只有对库做过明确授权才可以撤销对其的权限)

格式:

revoke grant option on 数据库名 from 用户名@"客户端地址";

实例:mysql> revoke grant option on userinfo.* form hydra@"192.168.4.254";

撤销指定的权限:

格式:revoke 权限列表 on 数据库名 from 用户名@"客户端地址";

实例:mysql> revoke delete on userinfo.* form hydra@"192.168.4.254";(撤销删除权限)


猜你喜欢

转载自blog.51cto.com/calabash/2139558