文章詳情頁(yè)
MySQL用戶權(quán)限設(shè)置保護(hù)數(shù)據(jù)庫(kù)安全
瀏覽:115日期:2023-05-08 10:17:41
目錄
- 更改mysql密碼
- 創(chuàng)建用戶
- 給用戶所有權(quán)限
- 移除用戶所有權(quán)限
- 添加部分權(quán)限
- 移除部分權(quán)限
- 刪除用戶
- 權(quán)限解釋
- 案例
更改mysql密碼
-- 查詢用戶權(quán)限 show grants for "root"@"%"; update mysql.user set authentication_string=password("密碼") where user="root" and Host = "localhost"; flush privileges; -- 或者下面方式 alter user "test1"@"localhost" identified by "新密碼"; flush privileges;
創(chuàng)建用戶
-- 創(chuàng)建本地的 -- create user "test1"@"localhost" identified by "密碼"; -- 創(chuàng)建可以遠(yuǎn)程訪問(wèn)的 create user "wjl"@"%" identified by "wujialiang";
給用戶所有權(quán)限
-- grant all privileges on *.* to "wjl"@"localhost" with grant option; grant all privileges on *.* to "wjl"@"%" with grant option;
第一個(gè)表示通配數(shù)據(jù)庫(kù),可指定新建用戶只可操作的數(shù)據(jù)庫(kù)
如:grant all privileges on 數(shù)據(jù)庫(kù). to ‘test1’@‘localhost’;
第二個(gè)*表示通配表,可指定新建用戶只可操作的數(shù)據(jù)庫(kù)下的某個(gè)表
如:grant all privileges on 數(shù)據(jù)庫(kù).指定表名 to ‘test1’@‘localhost’;
all privileges 可換成select,update,insert,delete,drop,create等操作 如:grant select,insert,update,delete on . to ‘test1’@‘localhost’;
移除用戶所有權(quán)限
-- revoke all privileges on *.* from "wjl"@"localhost"; revoke all privileges on *.* from "wjl"@"%";
添加部分權(quán)限
-- GRANT Select,Update,insert,delete ON *.* TO "用戶名"@"%"; GRANT select,update,insert,delete ON *.* TO "wjl"@"%";
移除部分權(quán)限
-- REVOKE select,insert ON 數(shù)據(jù)庫(kù).* FROM wjl@"localhost" REVOKE select,insert ON 數(shù)據(jù)庫(kù).* FROM wjl@"%"
刪除用戶
drop user "wjl"@"localhost";
權(quán)限解釋
案例
普通用戶權(quán)限
grant all privileges on *.* to "wjl"@"%" with grant option; REVOKE Shutdown,Process,Grant option,Drop ON *.* FROM wjl@"%"; flush privileges;
到此這篇關(guān)于MySQL用戶權(quán)限設(shè)置保護(hù)數(shù)據(jù)庫(kù)安全的文章就介紹到這了,更多相關(guān)MySQL用戶權(quán)限設(shè)置內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!
標(biāo)簽:
MySQL
排行榜
