1. 濡备綍璁剧疆mysql鐢ㄦ埛镄勬潈闄
1銆佸垱寤烘柊鐢ㄦ埛
阃氲繃root鐢ㄦ埛锏诲綍涔嫔悗鍒涘缓
>> grant all privileges on *.* to testuser@localhost identified by "123456" ;銆銆//銆銆鍒涘缓鏂扮敤鎴凤纴鐢ㄦ埛钖崭负testuser锛屽瘑镰佷负123456 锛
>> grant all privileges on *.* to testuser@localhost identified by "123456" ;銆銆//銆銆璁剧疆鐢ㄦ埛testuser锛屽彲浠ュ湪链鍦拌块梾mysql
>> grant all privileges on *.* to testuser@"%" identified by "123456" ;銆銆銆//銆銆璁剧疆鐢ㄦ埛testuser锛屽彲浠ュ湪杩灭▼璁块梾mysql
>> flush privileges ;銆銆//銆銆mysql 鏂拌剧疆鐢ㄦ埛鎴栨洿鏀瑰瘑镰佸悗闇鐢╢lush privileges鍒锋柊MySQL镄勭郴缁熸潈闄愮浉鍏宠〃锛屽惁鍒欎细鍑虹幇𨰾掔粷璁块梾锛岃缮链変竴绉嶆柟娉曪纴灏辨槸閲嶆柊钖锷╩ysql链嶅姟鍣锛屾潵浣挎柊璁剧疆鐢熸晥
2銆佽剧疆鐢ㄦ埛璁块梾鏁版嵁搴撴潈闄
>> grant all privileges on test_db.* to testuser@localhost identified by "123456" ;銆銆//銆銆璁剧疆鐢ㄦ埛testuser锛屽彧鑳借块梾鏁版嵁搴搕est_db锛屽叾浠栨暟鎹搴揿潎涓嶈兘璁块梾 锛
>> grant all privileges on *.* to testuser@localhost identified by "123456" ;銆銆//銆銆璁剧疆鐢ㄦ埛testuser锛屽彲浠ヨ块梾mysql涓婄殑镓链夋暟鎹搴 锛
>> grant all privileges on test_db.user_infor to testuser@localhost identified by "123456" ;銆銆//銆銆璁剧疆鐢ㄦ埛testuser锛屽彧鑳借块梾鏁版嵁搴搕est_db镄勮〃user_infor锛屾暟鎹搴扑腑镄勫叾浠栬〃鍧囦笉鑳借块梾 锛
3銆佽剧疆鐢ㄦ埛镎崭綔𨱒冮檺
>> grant all privileges on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;銆銆//璁剧疆鐢ㄦ埛testuser锛屾嫢链夋墍链夌殑镎崭綔𨱒冮檺锛屼篃灏辨槸绠$悊锻 锛
>> grant select on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;銆銆//璁剧疆鐢ㄦ埛testuser锛屽彧𨰾ユ湁銆愭煡璇銆戞搷浣沧潈闄 锛
>> grant select,insert on *.* to testuser@localhost identified by "123456" ;銆銆//璁剧疆鐢ㄦ埛testuser锛屽彧𨰾ユ湁銆愭煡璇\鎻掑叆銆戞搷浣沧潈闄 锛
>> grant select,insert,update,delete on *.* to testuser@localhost identified by "123456" ;銆銆//璁剧疆鐢ㄦ埛testuser锛屽彧𨰾ユ湁銆愭煡璇\鎻掑叆銆戞搷浣沧潈闄 锛
>> REVOKE select,insert ON what FROM testuser銆銆//鍙栨秷鐢ㄦ埛testuser镄勚愭煡璇\鎻掑叆銆戞搷浣沧潈闄 锛