ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] MySQL¸ê®Æ®wºÞ²z(Åv­­¡B¥¿³W¤Æ¡B³Ì¨Î¤Æ¡B¯Á¤Þ)

[¤À¨É] MySQL¸ê®Æ®wºÞ²z(Åv­­¡B¥¿³W¤Æ¡B³Ì¨Î¤Æ¡B¯Á¤Þ)

¤@¡B¸ê®Æ®w¥¿³W¤Æ
¥¿³W¤Æªº¥ØªºÂ²³æªº»¡´N¬O­n±N¸ê®Æªº­«ÂЩʭ°¦Ü³Ì§C¡]ÁקK¸ê®Æ­«½Æªºª¬ªpµo¥Í¡^¡C
²Ä¤@¥¿³W¤Æ¡]First Normal Form¡A²ºÙ 1NF¡^¡G²¾°£­«½Æªº¸s
id name part book1 book2 book3
1 §õ«º¨|±Ð°È³B1 4 3
­ì©l¸ê®Æªí
id name part book
1 §õ«º¨|±Ð°È³B1
2 §õ«º¨|±Ð°È³B4
3 §õ«º¨|±Ð°È³B3
¸g¹L²Ä¤@¥¿³W¤Æªº¸ê®Æªí

²Ä¤G¥¿³W¤Æ¡]Second Normal Form¡A²ºÙ 2NF¡^¡G²¾°£­«½Æ¥X²{ªº¸ê®Æ
name_id name part
1 §õ«º¨|±Ð°È³B
id name_id book
1 1 1
2 1 4
3 1 3
¸g¹L²Ä¤G¥¿³W¤Æªº¸ê®Æªí

²Ä¤T¥¿³W¤Æ¡]Third Normal Form¡A²ºÙ 3NF¡^¡G ²¾°£»P¥DÁä¨S¦³¥\¯à¬Û¨Ìªº¸ê®Æ
name_id name
1 §õ«º¨|
id part
1 ±Ð°È³B
¸g¹L²Ä¤T¥¿³W¤Æªº¸ê®Æªí

¤G¡BMySQLÅv­­¸ê®Æªí
(1) user
(2) db
(3) host
(4) table_priv
(5) column_priv
¡÷ user ¸ê®Æªí¬O¥Î¨Ó¨M©w¨Ï¥ÎªÌ¬O§_¯à³sµ²MySQL¦øªA¾¹
¡÷ db¡Bhost ¸ê®Æªí«h¬O¥Î¨Ó¨M©w­þ­Ó¸ê®Æ®w¬O¨Ï¥ÎªÌ¥i¥H¦s¨ú
¡÷ table_priv ¸ê®Æªí«h¬O¥Î¨Ó§P©w¸ê®Æ®w¤¤­þ¨Ç¸ê®Æªí¬O¨Ï¥ÎªÌ¥i¥H¦s¨ú
¡÷ column_priv ¸ê®Æªí«h¬O¥Î¨Ó§P©w¸ê®Æªí¤¤­þ¨ÇÄæ¦ì¬O¨Ï¥ÎªÌ¥i¥H¦s¨ú
2010/3/8 MySQL¸ê®Æ®wºÞ²z(Åv­­¡B¥¿³W¤Æ¡B⋯
dyna.hcc.edu.tw/php5/basic/⋯/class4_4.htm 1/3
¾Ç¸¹©m¦W
20001 §õ¤j©ú
20004 ½²«º¥É
20005 ¤è¾å´@
20003 ¦¿¾å­·
20002 ªL¸q¦p
±Æ§Ç
«á->
¾Ç¸¹©m¦W
20001 §õ¤j©ú
20002 ªL¸q¦p
20003 ¦¿¾å­·
20004 ½²«º¥É
20005 ¤è¾å´@
grant select,insert,update,delete on books.* to reader identified by '1234'
¡÷ ·s¼W¤@¦ì¨Ï¥ÎªÌreader ±K½X¬°1234 ¹ïbooks¸ê®Æ®w¤ºªº¸ê®Æªí¦³
select,insert,update,deleteÅv­­
grant all on books.* to reader identified by '1234'
¡÷ ·s¼W¤@¦ì¨Ï¥ÎªÌreader ±K½X¬°1234 ¹ïbooks¸ê®Æ®w¤ºªº¸ê®Æªí¦³©Ò¦³Åv­­
revoke all on books.* from reader
¡÷ ²¾°£¦bbooks¸ê®Æ®w¤¤ reader ©Ò¦³Åv­­
¤T¡B¯Á¤Þªº¨Ï¥Î
¯Á¤Þªº¦n³B¡G¬d¸ß·|¥[³t
¯Á¤Þªº¯ÊÂI¡G
1.¯Á¤ÞÀÉ·|¦ûÀɮתŶ¡
2.¸ê®Æ²§°Ê®É·|¸ûªá®É¶¡
¯Á¤Þª`·N¨Æ¶µ¡G
(1) ¦b MySQL ¸Ì¡A±NÄæ¦ì³]¬° Primary ®É¡A¦P®É¨ã¦³ index ªº®ÄªG¡C
(2) ±ý³]¬° index ªºÄæ¦ìªø«×¬O¶Vµu¶V¦n¡A³o¼Ë¦bºûÅ@ index table ®É·|§Ö³t¤@¨Ç¡F¹³
BLOB »P TEXT ³oÃþ¸ê®Æ«¬ºA¡A½Ð¤£­n³]¦¨¯Á¤Þ
¯Á¤Þªº«Ø¥ß¤è¦¡¡G
create table student (
id smallint not null auto_increment,
account varchar(12) binary not null,#µù¸Ñ¼g¦b³o¸Ì
name varchar(12) not null,
sex tinyint(1) default 0 ,
date datetime,
primary key(id),
index
name(account)
)
¥|¡B¸ê®Æ®wªº³Æ¥÷¡BÁÙ­ì¡BºÞ²z
¸ê®Æ®wªº³Æ¥÷
1. ¥Hroot ±b¸¹±K½Xµn¤J¡C
2. °õ¦æ¥H¤Uªº«ü¥O¡A±N¸ê®Æ¶×¥X¨ì ScriptÀÉ¡G# mysqldump -p book > backup.sql
3¿é¤J§Aªº±K½X«á¡A§¹¦¨¶×¥X¡C
2010/3/8 MySQL¸ê®Æ®wºÞ²z(Åv­­¡B¥¿³W¤Æ¡B⋯
dyna.hcc.edu.tw/php5/basic/⋯/class4_4.htm 2/3
¸ê®Æ®wªºÁÙ­ì
1. ¥Hroot ±b¸¹±K½Xµn¤J¡C
2. °õ¦æ¥H¤Uªº«ü¥O¡G#mysql -p book < backup.sql
3. ¿é¤J§Aªº±K½X«á¡A§¹¦¨ÁÙ­ì¡C
¸ê®Æ®wºÞ²z-phpMyAdmin

        ÀR«ä¦Û¦b : Ãø¦æ¯à¦æ¡AÃø±Ë¯à±Ë¡AÃø¬°¯à¬°¡A¤~¯àª@µØ¦Û§Úªº¤H®æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD