mysql許可權管理

2022-02-16 02:53:18 字數 893 閱讀 6106

1. 建立使用者

create user username identified by 'password' ;
2. 使用者授權

grant授權格式:grant 許可權列表 on 庫.表 to 'user_name'@'host name' identified by "密碼";

user_name是使用者名稱,host_name為主機名,即使用者連線mysql時所在主機的名字。

//授予使用者增刪改查許可權

grant select,insert,update,delete on *.* to 'user'@'%';

//給予全部許可權

grant all privileges on *.* to 'user'@'%' ;

//限制john使用者只有查詢cms資料庫的許可權,可限制到表

grant select on cms.* to 'john'@'127.0.0.1';

每次操作完要重新整理授權

flush privileges;
3. 檢視使用者許可權
show grants for '使用者'@'ip';

# show grants for 'root'@'127.0.0.1';

4. **許可權

revoke**許可權格式:revoke 許可權列表 on 庫.表 from 使用者名稱@'ip';

revoke select,insert,update,delete on *.* from 'user'@'%';
5. 刪除使用者
drop user 'john'@'127.0.0.1';

MySQL許可權管理

本文主要講述的是mysql grant命令的例項演示,文中的mysql grant命令的實際操作主要是在mysql 5.0 及以上的相關版本上執行,下面就是對其具體操作步驟的描述,望你在瀏覽之後會有所收穫。mysql 賦予使用者許可權命令的簡單格式可概括為 grant 許可權 on 資料庫物件 to...

mysql 許可權管理

1.新增使用者 方法一 create user wangda localhost identified by password 000000 說明 建立乙個本地的使用者,使用者名為 wangda 密碼為 000000 如果密碼為空,則 identified by password 000000 這個...

mysql許可權管理

mysqladmin u root p password leftpassword 無密碼的話直接回車 任意主機登入host換成 create user username host identified by password privileges all 代表所有許可權 表示全部的資料庫 gran...