mysql建立使用者

2021-09-06 20:28:44 字數 1451 閱讀 2852

1、建立本地使用者

create user 'ctgw'@'localhost' identified by 'ctgw'
2、賦權

create database testdb;

grant all privileges on *.* to 'ctgw'@'localhost' identified by 'ctgw';

grant all privileges on testdb.* to 'ctgw'@'localhost' identified by 'ctgw';

3、重新整理

flush privileges;
4、檢視使用者許可權

show grants for 'ctgw'@'localhost';
5、收回許可權

revoke all on *.* from 'ctgw'@'localhost';
檢視當前使用者的許可權

show grants;
賦權參考:

grant all on *.* to wang@'192.168.1.150' identified by "password";           //all等同於all privilege,其中的privileges可以省略

grant all privileges on *.* to wang@'192.168.1.%' identified by "123456";    表示乙個網段

grant insert,select,update,delete,drop,create,alter on huanqiu.* to wang@'%' identified by "123456";

flush privileges      //授權之後,不要忘記更新許可權表

收權參考:

revoke all on *.* from wang@'192.168.1.150';                  

revoke all privileges on *.* from wang@'192.168.1.%';              

revoke insert,select,update,delete,drop,create,alter on huanqiu.* from wang@'%';

flush privileges

如果想讓授權的使用者,也可以將這些許可權grant給其他使用者,那麼授權時需新增選項 "grant option"!

grant insert,select,update,alter on huanqiu.* to wang@'%' identified by "123456" with grant option;

mysql 建立使用者指令碼 Mysql使用者建立指令碼

我試圖自動化mysql使用者建立過程。我想到建立乙個包含mysql使用者建立語句的臨時檔案,那麼我會這樣稱呼 mysql u root proot 這裡是我的臨時檔案的內容 drop database if exists mytestdatabase create database mytestda...

mysql 建立使用者

mysql grant all privileges on to root identified by with grant option query ok,0 rows affected 0.02 sec 表示是所有的外部機器,如果指定某一台機,就將 改為相應的機器名 mysql grant al...

MYSQL 建立使用者

一,建立使用者 命令 create user username host identified by password 說明 username 你將建立的使用者名稱,host 指定該使用者在哪個主機上可以登陸,如果是本地使用者可用localhost,如果想讓該使用者可以從任意遠端主機登陸,可以使用萬...