MySQL建立使用者並分配許可權

2021-10-22 23:11:09 字數 604 閱讀 2476

1、建立使用者

create user 'username'@'host' identified by 'password';
username:使用者名稱。

host :指定該使用者在哪個主機上可以登陸,本地使用者可用localhost,如果從任意遠端主機登陸,可以使用萬用字元%。

password:該使用者的密碼。

2、分配許可權

grant all on databasename.tablename to 'username'@'host' identified by 'password';
privileges:使用者的操作許可權,如selectinsertupdate等,如果要授予所的許可權則使用all

databasename:資料庫名

tablename:表名,如果要授予該使用者對所有資料庫和表的相應操作許可權則可用*表示,如*.*

mysql建立使用者並分配許可權

mysql u root p 提示輸入密碼,輸入密碼後回車,進入mysql命令列 create user test identified by 123456 test為使用者名稱,123456為密碼,表示任何電腦都可以訪問,如果只為本地使用者建立,則 改為localhost grant select...

mysql建立使用者並分配許可權

允許本地 ip 訪問 localhost,127.0.0.1 create user test localhost identified by 123456 允許外網 ip 訪問 create user test identified by 123456 重新整理授權 flush privilege...

mysql 建立使用者 分配許可權

mysql建立使用者的方法分成三種 insert user表的方法 create user的方法 grant的方法。1 通過create user命令進行建立使用者 指令碼 create user username host identified by password 其中密碼是可選項 例子 cr...