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

MYSQLªì¾ÇªÌ¨Ï¥Î«ü«n

MYSQLªì¾ÇªÌ¨Ï¥Î«ü«n

¦³«Ü¦hªB¤ÍÁöµM¦w¸Ë¦n¤Fmysql¦ý«o¤£ª¾¦p¦ó¨Ï¥Î¥¦¡C¦b³o½g¤å³¹¤¤§Ú­Ì´N±q³s±µMYSQL¡B­×§ï±K½X¡B¼W¥[¨Ï¥ÎªÌµ¥¤è­±¨Ó¾Ç²ß¤@¨ÇMYSQLªº±`¥Î©R¥O¡C
¤@¡B³s±µMYSQL¡C
®æ¦¡¡G mysql -h¥D¾÷¦a§} -u¨Ï¥ÎªÌ¦W ¡Ðp¨Ï¥ÎªÌ±K½X
1¡B¨Ò1¡G³s±µ¨ì¥»¾÷¤WªºMYSQL¡C
­º¥ý¦b¥´¶}DOSµøµ¡¡AµM«á¶i¤J¥Ø¿ý mysqlbin¡A¦AÁä¤J©R¥Omysql -uroot -p¡A¦^¨®«á´£¥Ü§A¿é±K½X¡A¦pªG­è¦w¸Ë¦nMYSQL¡A¶W¯Å¨Ï¥ÎªÌroot¬O¨S¦³±K½Xªº¡A¬Gª½±µ¦^¨®§Y¥i¶i¤J¨ìMYSQL¤¤¤F¡AMYSQLªº´£¥Ü²Å¬O¡Gmysql>
2¡B¨Ò2¡G³s±µ¨ì»·µ{¥D¾÷¤WªºMYSQL¡C°²³]»·µ{¥D¾÷ªºIP¬°¡G110.110.110.110¡A¨Ï¥ÎªÌ¦W¬°root,±K½X¬°abcd123¡C«hÁä¤J¥H¤U©R¥O¡G
mysql -h110.110.110.110 -uroot -pabcd123
¡]ª`:u»Proot¥i¥H¤£¥Î¥[ªÅ®æ¡A¨ä¥¦¤]¤@¼Ë¡^
3¡B°h¥XMYSQL©R¥O¡G exit ¡]¦^¨®¡^
¤G¡B­×§ï±K½X¡C
®æ¦¡¡Gmysqladmin -u¨Ï¥ÎªÌ¦W -p±K½X password ·s±K½X
1¡B¨Ò1¡Gµ¹root¥[­Ó±K½Xab12¡C­º¥ý¦bDOS¤U¶i¤J¥Ø¿ýmysqlbin¡AµM«áÁä¤J¥H¤U©R¥O
mysqladmin -uroot -password ab12
µù¡G¦]¬°¶}©l®Éroot¨S¦³±K½X¡A©Ò¥H-p±K½X¤@¶µ´N¥i¥H¬Ù²¤¤F¡C
2¡B¨Ò2¡G¦A±Nrootªº±K½X§ï¬°djg345¡C
mysqladmin -uroot -pab12 password djg345
¤T¡B¼W¥[·s¨Ï¥ÎªÌ¡C¡]ª`·N¡G©M¤W­±¤£¦P¡A¤U­±ªº¦]¬°¬OMYSQLÀô¹Ò¤¤ªº©R¥O¡A©Ò¥H«á­±³£±a¤@­Ó¤À¸¹§@¬°©R¥Oµ²§ô²Å¡^
®æ¦¡¡Ggrant select on ¸ê®Æ®w.* to ¨Ï¥ÎªÌ¦W@µn¿ý¥D¾÷ identified by "±K½X"
¨Ò1¡B¼W¥[¤@­Ó¨Ï¥ÎªÌtest1±K½X¬°abc¡AÅý¥L¥i¥H¦b¥ô¦ó¥D¾÷¤Wµn¿ý¡A¨Ã¹ï©Ò¦³¸ê®Æ®w¦³¬d¸ß¡B´¡¤J¡B­×§ï¡B§R°£ªºÅv­­¡C­º¥ý¥Î¥Hroot¨Ï¥ÎªÌ³s¤JMYSQL¡AµM«áÁä¤J¥H¤U©R¥O¡G
grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
¦ý¨Ò1¼W¥[ªº¨Ï¥ÎªÌ¬O¤Q¤À¦MÀIªº¡A§A·Q¦p¬Y­Ó¤Hª¾¹Dtest1ªº±K½X¡A¨º»ò¥L´N¥i¥H¦binternet¤Wªº¥ô¦ó¤@¥x¹q¸£¤Wµn¿ý§Aªºmysql¸ê®Æ®w¨Ã¹ï§Aªº¸ê®Æ¥i¥H¬°©Ò±ý¬°¤F¡A¸Ñ¨M¿ìªk¨£¨Ò2¡C
¨Ò 2¡B¼W¥[¤@­Ó¨Ï¥ÎªÌtest2±K½X¬°abc,Åý¥L¥u¥i¥H¦blocalhost¤Wµn¿ý¡A¨Ã¥i¥H¹ï¸ê®Æ®wmydb¶i¦æ¬d¸ß¡B´¡¤J¡B­×§ï¡B§R°£ªº¾Þ§@¡]localhost«ü¥»¦a¥D¾÷¡A§YMYSQL¸ê®Æ®w©Ò¦bªº¨º¥x¥D¾÷¡^¡A³o¼Ë¨Ï¥ÎªÌ§Y¨Ï¥Îª¾¹Dtest2ªº±K½X¡A¥L¤]µLªk±qinternet¤Wª½±µ³X°Ý¸ê®Æ®w¡A¥u¯à³q¹LMYSQL¥D¾÷¤Wªºweb­¶¨Ó³X°Ý¤F¡C
grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
¦pªG§A¤£·Qtest2¦³±K½X¡A¥i¥H¦A¥´¤@­Ó©R¥O±N±K½X®ø±¼¡C
grant select,insert,update,delete on mydb.* to test2@localhost identified by "";


(¤U½g)
¦b¤W½g§Ú­ÌÁ¿¤Fµn¿ý¡B¼W¥[¨Ï¥ÎªÌ¡B±K½X§ó§ïµ¥°ÝÃD¡C¤U½g§Ú­Ì¨Ó¬Ý¬ÝMYSQL¤¤¦³Ãö¸ê®Æ®w¤è­±ªº¾Þ§@¡Cª`·N¡G§A¥²¶·­º¥ýµn¿ý¨ìMYSQL¤¤¡A¥H¤U¾Þ§@³£¬O¦bMYSQLªº´£¥Ü²Å¤U¶i¦æªº¡A¦Ó¥B¨C­Ó©R¥O¥H¤À¸¹µ²§ô¡C

¤@¡B¾Þ§@§Þ¥©
1¡B¦pªG§A¥´©R¥O®É¡A¦^¨®«áµo²{§Ñ°O¥[¤À¸¹¡A§AµL¶·­«¥´¤@¹M©R¥O¡A¥u­n¥´­Ó¤À¸¹¦^¨®´N¥i¥H¤F¡C¤]´N¬O»¡§A¥i¥H§â¤@­Ó§¹¾ãªº©R¥O¤À¦¨´X¦æ¨Ó¥´¡A§¹«á¥Î¤À¸¹§@µ²§ô¼Ð»x´NOK¡C
2¡B§A¥i¥H¨Ï¥Î¥ú¼Ð¤W¤UÁä½Õ¥X¥H«eªº©R¥O¡C¦ý¥H«e§Ú¥Î¹Lªº¤@­ÓMYSQLª©¥»¤£¤ä«ù¡C§Ú²{¦b¥Îªº¬Omysql-3.23.27-beta-win¡C

¤G¡BÅã¥Ü©R¥O
1¡BÅã¥Ü¸ê®Æ®w¦Cªí¡C
show databases;
­è¶}©l®É¤~¨â­Ó¸ê®Æ®w¡Gmysql©Mtest¡Cmysql®w«Ü­«­n¥¦¸Ì­±¦³MYSQLªº¨t²Î°T®§¡A§Ú­Ì§ï±K½X©M·s¼W¨Ï¥ÎªÌ¡A¹ê»Ú¤W´N¬O¥Î³o­Ó®w¶i¦æ¾Þ§@¡C
2¡BÅã¥Ü®w¤¤ªº¸ê®Æªí¡G
use mysql¡F ¡þ¡þ¥´¶}®w¡A¾Ç¹LFOXBASEªº¤@©w¤£·|­¯¥Í§a
show tables;
3¡BÅã¥Ü¸ê®Æªíªºµ²ºc¡G
describe ªí¦W;
4¡B«Ø®w¡G
create database ®w¦W;
5¡B«Øªí¡G
use ®w¦W¡F
create table ªí¦W (¦r¬q³]©w¦Cªí)¡F
6¡B§R®w©M§Rªí:
drop database ®w¦W;
drop table ªí¦W¡F
7¡B±Nªí¤¤°O¿ý²MªÅ¡G
delete from ªí¦W;
8¡BÅã¥Üªí¤¤ªº°O¿ý¡G
select * from ªí¦W;

¤T¡B¤@­Ó«Ø®w©M«Øªí¥H¤Î´¡¤J¸ê®Æªº¹ê¨Ò
drop database if exists school; //¦pªG¦s¦bSCHOOL«h§R°£
create database school; //«Ø¥ß®wSCHOOL
use school; //¥´¶}®wSCHOOL
create table teacher //«Ø¥ßªíTEACHER
(
id int(3) auto_increment not null primary key,
name char(10) not null,
address varchar(50) default '²`¦`',
year date
); //«Øªíµ²§ô
//¥H¤U¬°´¡¤J¦r¬q
insert into teacher values('','glchengang','²`¦`¤@¤¤','1976-10-10');
insert into teacher values('','jack','²`¦`¤@¤¤','1975-12-23');

µù¡G¦b«Øªí¤¤¡]1¡^±NID³]¬°ªø«×¬°3ªº¼Æ¦r¦r¬q:int(3)¨ÃÅý¥¦¨C­Ó°O¿ý¦Û°Ê¥[¤@:auto_increment¨Ã¤£¯à¬°ªÅ:not null¦Ó¥BÅý¥L¦¨¬°¥D¦r¬qprimary key¡]2¡^±NNAME³]¬°ªø«×¬°10ªº¤å¦r¦r¬q¡]3¡^±NADDRESS³]¬°ªø«×50ªº¤å¦r¦r¬q¡A¦Ó¥B¯Ê¬Ù­È¬°²`¦`¡Cvarchar©Mchar¦³¤°»ò°Ï§O©O¡A¥u¦³µ¥¥H«áªº¤å³¹¦A»¡¤F¡C ¡]4¡^±NYEAR³]¬°¤é´Á¦r¬q¡C
¦pªG§A¦bmysql´£¥Ü²ÅÁä¤J¤W­±ªº©R¥O¤]¥i¥H¡A¦ý¤£¤è«K½Õ¸Õ¡C§A¥i¥H±N¥H¤W©R¥O­ì¼Ë¼g¤J¤@­Ó¤å¥»¤å¥ó¤¤°²³]¬°school.sql¡AµM«á½Æ»s¨ìc:\¤U¡A¨Ã¦bDOSª¬ºA¶i¤J¥Ø¿ý\mysql\bin¡AµM«áÁä¤J¥H¤U©R¥O¡G
mysql -uroot -p±K½X < c:\school.sql
¦pªG¦¨¥\¡AªÅ¥X¤@¦æµL¥ô¦óÅã¥Ü¡F¦p¦³¿ù»~¡A·|¦³´£¥Ü¡C¡]¥H¤W©R¥O¤w¸g½Õ¸Õ¡A§A¥u­n±N//ªºµùÄÀ¥h±¼§Y¥i¨Ï¥Î¡^¡C

¥|¡B±N¤å¥»¸ê®ÆÂà¨ì¸ê®Æ®w¤¤
1¡B¤å¥»¸ê®ÆÀ³²Å¦Xªº®æ¦¡¡G¦r¬q¸ê®Æ¤§¶¡¥ÎtabÁä¹j¶}¡Anull­È¥Î\n¨Ó¥N´À.
¨Ò¡G
3 rose ²`¦`¤G¤¤ 1976-10-10
4 mike ²`¦`¤@¤¤ 1975-12-23
2¡B¸ê®Æ¶Ç¤J©R¥O load data local infile "¤å¥ó¦W" into table ªí¦W;
ª`·N¡G§A³Ì¦n±N¤å¥ó½Æ»s¨ì\mysql\bin¥Ø¿ý¤U¡A¨Ã¥B­n¥ý¥Îuse©R¥O¥´ªí©Ò¦bªº®w ¡C

¤­¡B³Æ¥÷¸ê®Æ®w¡G¡]©R¥O¦bDOSªº\mysql\bin¥Ø¿ý¤U°õ¦æ¡^
mysqldump --opt school>school.bbb
µùÄÀ:±N¸ê®Æ®wschool³Æ¥÷¨ìschool.bbb¤å¥ó¡Aschool.bbb¬O¤@­Ó¤å¥»¤å¥ó¡A¤å¥ó¦W¥ô¨ú¡A¥´¶}¬Ý¬Ý§A·|¦³·sµo²{¡C
­Ó¤Hñ¦W@

        ÀR«ä¦Û¦b : ÀR§¤±`®¦¤v¹L¡B¶¢½Í²ö½×¤H«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD