1.使用root賬號登陸到MySQL伺服器: 2.切換到mysql資料庫實例: 3.查看用戶表: 4.創建一個只允許從本機登錄的用戶“yang”,密碼為“yangpass”: 5.刪除一個名為“yang”的本機登錄用戶: 6.創建一個允許從任何主機登錄的用戶“yang”,密碼為“yangpass”: ...
1.使用root賬號登陸到MySQL伺服器:
mysql -u root -pmypass;
2.切換到mysql資料庫實例:
use mysql;
3.查看用戶表:
select host, user, password from user;
4.創建一個只允許從本機登錄的用戶“yang”,密碼為“yangpass”:
create user 'yang'@'localhost' identified by 'yangpass';
5.刪除一個名為“yang”的本機登錄用戶:
drop user 'yang'@'localhost';
6.創建一個允許從任何主機登錄的用戶“yang”,密碼為“yangpass”:
create user 'yang'@'%' identified by 'yangpass';
7.修改允許從任何主機登錄的用戶“yang”的密碼,新密碼為“yan”:
set password for 'yang'@'%' = password('yan');
8.向允許從任意主機登錄的名為“yang”的用戶,授予yang_test的庫的所有許可權:
grant all privileges on yang_test.* to 'yang'@"%";
9.刷新許可權,使許可權修改生效:
flush privileges;
10.創建一個允許從任何主機登錄的用戶“remote”,密碼為“app”:
create user 'remote'@'%' identifed by 'app';
11.給“remote”用戶授予庫“yang_test”上的“t_weapon”表的CRUD許可權:
grant select, delete, update, insert on yang_test.t_weapon to 'remote';
12.撤銷用戶“yang”在“yang_test”庫上的所有許可權:
revoke all privileges on yang_test.* from 'yang'@'%';