mysql8建立不了使用者 mysql8建立使用者

2021-10-17 17:00:34 字數 1195 閱讀 1745

假如是mysql8版本的話,使用

grant all privileges *.* to '使用者'@'localhost' identified by '自定義密碼';

會報錯,因為要先建立使用者再進行賦權,不能同時進行

建立使用者

create user '使用者名稱'@'localhost' identified by '密碼';

flush privileges;重新整理許可權

其中localhost指本地才可連線

可以將其換成%指任意ip都能連線

也可以指定ip連線(192.168.110.131)

或者某個網段(192.168.110.%)

修改密碼

alter user '使用者'@'localhost' identified by '新密碼';

flush privileges;

授權grant all privileges on *.* to '使用者'@'localhost' with grant option;

with gran option表示該使用者可給其它使用者賦予許可權,但不可能超過該使用者已有的許可權

比如a使用者有select,insert許可權,也可給其它使用者賦權,但它不可能給其它使用者賦delete許可權,除了select,insert以外的都不能

這句話可加可不加,視情況而定。

all privileges 可換成select,update,insert,delete,drop,create等操作

如:grant select,insert,update,delete on . to '使用者'@'localhost';

第乙個*表示通配資料庫,可指定新建使用者只可操作的資料庫

如:grant all privileges on 資料庫.* to '使用者'@'localhost';

第二個*表示通配表,可指定新建使用者只可操作的資料庫下的某個表

如:grant all privileges on 資料庫.指定表名 to '使用者'@'localhost';

檢視使用者授權

show grants for '使用者'@'localhost';

撤銷許可權

revoke all privileges on *.* from '使用者'@'localhost';

使用者有什麼許可權就撤什麼許可權

刪除使用者

drop user '使用者'@'localhost';

mysql8建立使用者

create user test user identified by test2022 grant allprivileges on test.to test user with grant option flush privileges 這樣就可以建立乙個叫 test user 的使用者並把密碼...

MySQL8使用者管理

mysql create user user1 localhost identified by 123456 identified by 後面是密碼,直接寫就可,不需再加password 函式。使用剛剛建立的使用者登入,然後執行show databases會發現只有乙個名為information s...

mysql8 建立使用者賬號以及賦予使用者許可權

建立使用者並設定密碼 123456 是密碼 create user test localhost identified by 123456 create user test identified by 123456 其中localhost指本地才可連線 可以將其換成 指任意ip都能連線 也可以指定i...