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

2022-08-21 19:00:15 字數 1184 閱讀 9696

允許本地 ip 訪問 localhost, 127.0.0.1

create

user

'test

'@'localhost

' identified by

'123456

';

允許外網 ip 訪問

create

user

'test

'@'%

' identified by

'123456

';

重新整理授權

flush privileges;

create

database test default charset utf8 collate utf8_general_ci;

授予使用者通過外網ip對於該資料庫的全部許可權

grant

allprivileges

on `testdb`.*to'

test

'@'%

' identified by

'123456

';

授予使用者在本地伺服器對該資料庫的全部許可權

grant

allprivileges

on `testdb`.*to'

test

'@'localhost

' identified by

'123456

';

重新整理許可權

flush privileges;

用新帳號 test 重新登入,由於使用的是 % 任意ip連線,所以需要指定外部訪問ip

mysql -u test -h 115.28.203.224

-p

# instead of skip-networking the default

is now to listen only

on# localhost which

is more compatible and

isnot

less secure.

#bind

-address =

127.0.0.1 #注釋掉這一行就可以遠端登入了

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

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

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

1 建立使用者 create user username host identified by password username 使用者名稱。host 指定該使用者在哪個主機上可以登陸,本地使用者可用localhost,如果從任意遠端主機登陸,可以使用萬用字元 password 該使用者的密碼。2...

mysql 建立使用者 分配許可權

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