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";(撤銷刪除權限)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章