MySQL新建使用者詳細說明

2021-09-12 18:02:49 字數 1526 閱讀 2468

create user 'username'@'host' identified by 'password';
create user 'dog'@'localhost' identified by '123456';

create user 'pig'@'192.168.1.101_' idendified by '123456';

create user 'pig'@'%' identified by '123456';

create user 'pig'@'%' identified by '';

create user 'pig'@'%';

grant privileges on databasename.tablename to 'username'@'host'
grant select, insert on test.user to 'pig'@'%';

grant all on *.* to 'pig'@'%';

grant all on maindataplus.* to 'pig'@'%';

用以上命令授權的使用者不能給其它使用者授權,如果想讓該使用者可以授權,用以下命令:

grant privileges on databasename.tablename to 'username'@'host' with grant option;
set password for 'username'@'host' = password('newpassword');
如果是當前登陸使用者用:

set password = password("newpassword");
set password for 'pig'@'%' = password("123456");
revoke privilege on databasename.tablename from 'username'@'host';
privilege, databasename, tablename:同授權部分

revoke select on *.* from 'pig'@'%';
假如你在給使用者'pig'@'%'授權的時候是這樣的(或類似的):grant select on test.user to 'pig'@'%',則在使用revoke select on *.* from 'pig'@'%';命令並不能撤銷該使用者對test資料庫中user表的select操作。相反,如果授權使用的是grant select on *.* to 'pig'@'%';revoke select on test.user from 'pig'@'%';命令也不能撤銷該使用者對test資料庫中user表的select許可權。

具體資訊可以用命令show grants for 'pig'@'%';檢視。

drop user 'username'@'host';

MySQL的explain詳細說明

explain顯示了mysql如何使用索引來處理select語句以及連線表。可以幫助選擇更好的索引和寫出更優化的查詢語句。使用方法,在select語句前加上explain就可以了 如 explain select surname,first name form a,b where a.id b.id...

mysql事務的詳細說明

事務由一組操作構成,我們希望這組操作能夠全部正確執行,如果這一組操作中的任意乙個步驟發生錯誤,那麼就需要回滾之前已經完成的操作。也就是同乙個事務中的所有操作,要麼全都正確執行,要麼全都不要執行。說到事務,就不得不提一下事務著名的四大特性。注意 事務只能保證資料庫的高可靠性,即資料庫本身發生問題後,事...

Struts config xml 詳細說明

頁面中表單對應的bean儲存表單資料,驗證 type hello.helloform formbean 對應的包名.類名 路徑的邏輯名,此項必須有 path action1.do 指向 或重定向的uri.此項是必需的,必須以 開頭.請求訪問action的路徑,必須以 開頭 type hello.he...