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鐨勩愭煡璇\鎻掑叆銆戞搷浣滄潈闄 錛