mysql 新增使用者 授權

2022-08-11 18:36:16 字數 1139 閱讀 6009

參考:

1.create user test identified by 'test'; 建立使用者test,密碼為test

2.設定許可權

語句格式:grant select on 資料庫.* to 使用者名稱@登入主機 identified by "密碼" ;

例如:

讓他可以在任何主機上登入,並對所有資料庫有查詢、插入、修改、刪除的許可權。

首先用以root使用者連入mysql,然後鍵入以下命令:

grant select,insert,update,delete on *.* to test@"%" identified by "test";

若只可以在localhost上登入,並可以對資料庫mydb進行 查詢、插入、修改、刪除的操作(localhost指本地主機,即mysql資料庫所在的那台主機),這樣使用者即使用知道test的密碼,他也無法從 internet上直接訪問資料庫,只能通過mysql主機上的web頁來訪問

grant select,insert,update,delete on mydb.* to test@localhost identified by "test";

如果你不想test有密碼,可以打乙個命令將密碼消掉

grant select,insert,update,delete on mydb.* to test@localhost identified by "";

指定使用者擁有建立表的許可權

grant select,insert,update,delete,create,drop on mydb.* to test@localhost identified by "test";

3.重新整理資料庫

flush privileges;

4.檢視使用者資訊

select host,user from mysql.user;

增加普通使用者後可能無法登入,可嘗試刪除匿名使用者,執行:

mysql> use mysql

mysql> delete from user where user='';

mysql> flush privileges;

刪除匿名使用者後可以了。

mysql新增使用者授權

create user username host identified by password create user dog localhost identified by 123456 create user pig 192.168.1.101 idendified by 123456 cre...

MySQL使用者管理 新增使用者 授權

新增使用者 以root使用者登入資料庫,執行以下命令 create user test identified by test 上面的命令建立了使用者test,密碼是test。在mysql.user表裡可以檢視到新增使用者的資訊 授權命令格式 grant privilegescode on dbnam...

MySQL新增使用者使用者與授權

mysql中新增使用者,新建資料庫,使用者授權,刪除使用者,修改密碼 注意每行後邊都跟個 表示乙個命令語句結束 1.新建使用者 登入mysql mysql u root p 密碼 建立使用者 mysql insert into mysql.user host,user,password values...