: S& e; b, y) y! d ~# m+ v# J【說明】 ! `1 E$ n3 g# h+ JMySQL資料庫授權有分成本機及遠端,例如,一個帳號綁定給localhost的話,那該帳號只能在MySQL資料庫本機使用,要開放給遠端主機連線到MySQL資料庫主機的話,那就必須將帳號綁定給遠端主機使用,下方介紹方式都是授權或刪除所有權限,MySQL權限有很多可以參考下列: 3 ^! x" `' c7 c+ H! C" L5 V ) I: v1 Q" q1 I% G7 n a0 d7 T& J. [. _3 Z 2 D! L3 }, q3 {* t3 R ` J資料庫(DateBase)十五種權限: ; f7 O/ z8 k% |' G' {" B# q( d" i9 h
7 }3 k4 l N l9 A! d
ALL PRIVILEGES、ALTER、CREATE、DELETE、DROP、FILE、INDEX、INSERT、PROCESS、REFERENCES、RELOAD、SELECT、SHUTDOWN、UPDATE、USAGE' G- q% @; z! h! L8 V
0 c/ \! M& l8 T0 l q% }
6 V) g8 C0 m9 T
7 Q! B7 I3 J$ c7 U* l3 u % _; M- g: D p1 q& S5 }資料表(Table)八種權限: 4 k# ^* N! D4 x! H9 y: D: W( |4 m) w W- _3 V; _
2 u: ?, s. |! B, r: X$ ]" K. ASELECT、INSERT、UPDATE、DELETE、CREATE、DROP、INDEX、ALTER' x- N- A9 S0 x1 @
7 [* h0 {( u7 v$ Q; A6 X1 B 5 I" u \# H4 h6 V' T/ Z$ t# @: `! f" N$ G# e
' r3 K- q6 G1 @0 C/ @; H資料欄(column)三種權限:. S4 ?1 b* @4 b. K9 z, a, X, b" S
% a, O8 n/ @( j; P2 V - H1 n- N2 `% q9 X1 s* g; CSELECT INSERT UPDATE ) {, `: k! z5 [. S1 k% J8 z" F0 f. d/ d' M, W4 r/ L
) F) t( I7 n$ \0 \( W& ^5 Y
{# `+ b0 ?1 z8 y8 t6 X【實例:】 M: p. E( _6 g0 n/ l4 z
- c* k+ [8 G- _# i/ a
& {4 |, G- i8 H/ ]2 W8 Y8 M[root@localhost ~]# mysql -u root -p 3 g% k; T1 d/ q& i s' m: zEnter password: & ~1 i7 A+ S$ B- w; K5 dWelcome to the MySQL monitor. Commands end with ; or \g. 4 X9 ?( s' u2 J }/ @7 d8 qYour MySQL connection id is 2 ) Q- T2 v' B; MServer version: 5.1.52 Source distribution ) E. l3 d: b$ [4 Y* K& SCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved." B! p$ r5 m% |7 |
This software comes with ABSOLUTELY NO WARRANTY. This is free software,' r; i3 ?7 Y2 H6 d
and you are welcome to modify and redistribute it under the GPL v2 license4 }4 X1 a' X; @. u% o2 V+ B' R
* L0 m* N: R& L1 I
; J; `, g& l" j6 E1 M1 p R. vType 'help;' or '\h' for help. Type '\c' to clear the current input statement.0 Z+ H0 x* @: v' o/ h# X @ S
7 F( e9 |9 G( @4 k8 O/ p- f3 T
( W8 b# X4 H. Z2 X, v4 h
mysql> grant all privileges on *.* to test@localhost identified by '1234567'; //第一個星號是database,第二個星號是table/ }, \0 ~# B- ?" E% q, T- ]8 u. Q
@/ ~, j- o5 D: o, L% Z& G 1 [% u; U. K7 K6 p& vQuery OK, 0 rows affected (0.00 sec) //建立test帳號本機權限9 R1 x3 n3 t, d7 T, T' E2 _2 N
5 u& }6 t5 C" ~5 _$ P
4 L% o! c$ |6 R2 S+ g8 A9 o1 x
mysql> grant all privileges on *.* to test@192.168.1.2 identified by '1234567';4 G4 E @( W% k, _$ V( C
9 R3 I7 b/ p2 Z+ w