1. 程式人生 > >mysql下建立帳號並授予全部許可權

mysql下建立帳號並授予全部許可權

create user ‘kugou’@’%’ identified by ‘[email protected]’; 其中kugou為使用者。%:匹配所有主機,該地方還可以設定成‘localhost’,代表只能本地訪問,例如root賬戶預設為‘localhost‘ [email protected]為密碼。

grant select,insert,update,delete,create on [資料庫名稱].* to [使用者名稱稱];–使用者授權資料庫 *代表整個資料庫

mysql> grant select,insert,update,delete,create on sys.* to kugou; mysql> grant select,insert,update,delete,create on performance_schema.* to kugou; mysql> grant select,insert,update,delete,create on mysql.* to kugou; information_schema.資料庫在建立使用者時就擁有的許可權。 mysql> flush privileges; revoke all on .

from kugou;–取消使用者所有資料庫(表)的所有許可權 delete from mysql.user where user=‘kugou’;–刪除使用者

create user ‘dst’@’%’ identified by ‘dstyl!1’; grant all privileges on . to ‘dst’@’%'identified by ‘dstyl!1’ with grant option; 可以給予全部許可權

create user ‘dsttest’@’%’ identified by ‘dstt1!t’; grant select on . to ‘dsttest’@’%'identified by 'dstt1!t’with grant option; use mysql; show grants for dsttest;檢視帳號許可權