mysql使用者授權 mysql使用者許可權管理

2021-10-17 22:38:59 字數 2824 閱讀 7793

-- 查詢資料庫使用者

select user

-- 使用ip鏈結資料庫(%匹配所有)

mysql -h192.168.1.% -ulisi -p***x;

-- 修改host域,使ip可以鏈結上

update user set host='192.168.1.%' where user='root';

flush privileges;

-- 修改使用者密碼,password()對密碼加密

update user set password=password('11111') where ***x;

flush privileges;

-- 檢視使用者以及許可權

select * from user where user='lisi' \g;

-- 檢視庫表的級別和host鏈結狀態

select * from db \g;

select * from table \g;

-- 新增使用者並賦予全域性許可權

-- 常用的許可權all,create,drop,insert,delete,update,select

-- 比如grant all on *.* to lisi@'192.168.1.%' identfied by'1111';

grant [許可權1,許可權2,許可權3.。] on *.* to user@'host' identfied by'password';

-- **全域性許可權

-- 比如revoke all on *.* from lisi@'192.168.1.%';

revoke all on *.* from user@'host' identfied by'password';

-- 針對庫做授權

-- 比如grant all on test.* to lisi@'192.168.1.%';

grant all on tbname.* to lisi@'192.168.1.%';

revoke all on tbname.* to lisi@'192.168.1.%';

-- 針對表做授權

-- 比如grant insert,update,select on test.goods to lisi@'192.168.1.%';

grant insert,update,select on dbname.tbname to lisi@'192.168.1.%';

revoke all on dbname.tbname to lisi@'192.168.1.%';

-- mysql新增遠端使用者或允許遠端訪問三種方法

-- 新增遠端使用者admin密碼為password

grant all privileges on *.* to admin@localhost identified by password with grant option;

grant all privileges on *.* to admin@\"%\" identified by password   with grant option;

-- 用root使用者登陸,然後:

grant all privileges on *.* to username @"%" identified by "密碼";

flush privileges; * 重新整理剛才的內容*

-- % 代表任意的客戶端,如果填寫 localhost 為本地訪問(那麼 使用者就不能遠端訪問該mysql資料庫了,在伺服器上localhost是指伺服器主機)。

-- 同時也可以為現有的使用者設定是否具有遠端訪問許可權。如下:

use mysql;

update db set host = '%' where user = 'username'; (如果寫成 host=localhost 那此使用者就不具有遠端訪問許可權)

flush privileges;

grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;

-- 使用grant語句新增:

-- 首先在資料庫本機上用root使用者登入mysql(我是用遠端控制linux伺服器,相當於在伺服器本機登入mysql了),然後輸入:

grant all privileges on *.* to admin@localhost identified by 'password' with grant option;

-- 新增乙個使用者admin並授權可從任何其它主機(localhost)發起的訪問(萬用字元%)。使用這一條語句即可。

grant all privileges on *.* to admin@"%" identified by 'password' with grant option;

-- 使用insert語句:

-- 使用者資訊可在mysql資料庫中的users表中檢視,這裡不在介紹了就。數清y的個數哦。

-- 好了,使用admin帳號連線試試看,我是屢試屢成功哦,呵呵!

insert into user values('%','admin',password('password'), 'y','y','y','y','y','y','y','y','y','y','y','y','y','y');

-- 新增遠端使用者admin密碼為password

grant all privileges on *.* to admin@localhost identified by 'password' with grant option;

grant all privileges on *.* to admin@"%" identified by 'password' with grant option;

mysql 授權 mysql 使用者授權

mysql grant 許可權1,許可權2,許可權n on 資料庫名稱.表名稱 to 使用者名稱 使用者位址 identified by 連線口令 許可權1,許可權2,許可權n代表select,insert,update,delete,create,drop,index,alter,grant,re...

mysql授權使用者許可權 mysql授權使用者許可權

grant 普通資料使用者,查詢 插入 更新 刪除 資料庫中所有表資料的權利。grant select on testdb.to common user grant insert on testdb.to common user grant update on testdb.to common us...

mysql授權 MySQL使用者授權(GRANT)

當成功建立使用者賬戶後,還不能執行任何操作,需要為該使用者分配適當的訪問許可權。可以使用 show grant for 語句來查詢使用者的許可權。注意 新建立的使用者只有登入 mysql 伺服器的許可權,沒有任何其他許可權,不能進行其他操作。usage on 表示該使用者對任何資料庫和任何表都沒有許...