Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MysqlµÄÐÐËø»úÖÆ


<!-- [if gte mso 10]>
ÒÔÏÂÄÚÈÝÀ´×ÔÍøÂ磬ÒѲâÊÔ¡£
½áÂÛ£º
mysql
ÐÐËø²»°²È«£¬ËæÊý¾ÝµÄ±ä»¯£¬¿ÉÄÜ»á³öÏÖÐÐËøÎÞЧ£¡Òò´Ë£¬·ÇÈ·¶¨Çé¿öÏ£¬²»Òª¶Ô
mysql
±í¼ÓÐÐËøÀ´¿ØÖÆÒµÎñÂß¼­¡£
ÓÉÓÚÒµÎñÂß¼­µÄÐèÒª£¬±ØÐë¶ÔÊý¾Ý±íµÄÒ»Ðлò¶àÐмÓÈëÐÐËø£¬¾Ù¸ö×î¼òµ¥µÄÀý×Ó£¬Í¼Êé½èÔÄϵͳ¡£¼ÙÉè
id=1
µÄÕâ±¾Êé¿â´æΪ
1
£¬µ«ÊÇÓÐ
2
¸öÈËͬʱÀ´½èÕâ±¾Ê飬´Ë´¦µÄÂß¼­Îª
Select  
restnum 
from 
book 
where 
id =1 ;   
--
Èç¹û
restnum
´óÓÚ
0
£¬Ö´ÐÐ
update
Update  
book 
set restnum=restnum-1 where
id=1 ;
 
ÎÊÌâ¾ÍÀ´ÁË£¬µ±
2
¸öÈËͬʱÀ´½èµÄʱºò£¬ÓпÉÄܵÚÒ»¸öÈËÖ´ÐÐ
select
Óï¾äµÄʱºò£¬µÚ¶þ¸öÈ˲åÁ˽øÀ´£¬ÔÚµÚÒ»¸öÈËûÀ´µÃ¼°¸üÐÂ
book
±íµÄʱºò£¬µÚ¶þ¸öÈ˲鵽Êý¾ÝÁË£¬ÆäʵÊÇÔàÊý¾Ý£¬ÒòΪµÚÒ»¸öÈË»á°Ñ
restnum
Öµ¼õ
1
£¬Òò´ËµÚ¶þ¸öÈ˱¾À´Ó¦¸ÃÊDz鵽
id=1
µÄÊé
restnum
Ϊ
0
ÁË£¬Òò´Ë²»»áÖ´ÐÐ
update
£¬¶ø»á¸æËßËü
id=1
µÄÊéûÓпâ´æÁË£¬¿ÉÊÇÊý¾Ý¿âÄĶ®ÕâЩ£¬Êý¾Ý¿âÖ»¸ºÔðÖ´ÐÐÒ»ÌõÌõ
SQL
Óï¾ä£¬Ëü²Å²»¹ÜÖмäÓÐûÓÐÆäËû
sql
Óï¾ä²å½øÀ´£¬ËüÒ²²»ÖªµÀÒª°ÑÒ»¸ö
session
µÄ
sql
Óï¾äÖ´ÐÐÍêÔÙÖ´ÐÐÁíÒ»¸ö
session
µÄ¡£Òò´Ë»áµ¼Ö²¢·¢µÄʱºò
restnum
×îºóµÄ½á¹ûΪ
-1
£¬ÏÔÈ»ÕâÊDz»ºÏÀíµÄ£¬ËùÒÔ£¬²Å³öÏÖËøµÄ¸ÅÄ
Mysql
ʹÓÃ
innodb
ÒýÇæ¿ÉÒÔͨ¹ýË÷Òý¶ÔÊý¾ÝÐмÓËø¡£ÒÔÉϽèÊéµÄÓï¾ä±äΪ£º
 
Begin;
Select 
restnum 
from 
book 
where 
id =1 
for 
update ; --
¸ø
id=1
µÄÐмÓÉÏÅÅËüËøÇÒ
id
ÓÐË÷Òý
Update  
book 
set restnum=restnum-1 where
id=1 ;
Commit;
 
ÕâÑù£¬µÚ¶þ¸öÈËÖ´Ðе½
select
Óï¾äµÄʱºò¾Í»á´¦Óڵȴý״ֱ̬µ½µÚÒ»¸öÈËÖ´ÐÐ
commit
¡£´Ó¶ø±£Ö¤Á˵ڶþ¸öÈ˲»»á¶Áµ½µÚÒ»¸öÈËÐÞ¸ÄÇ°µÄÊý¾Ý¡£
 
ÄÇÕâÑùÊDz»ÊÇÍòÎÞһʧÁËÄØ£¬´ð°¸ÊÇ·ñ¶¨µÄ¡£¿´ÏÂÃæµÄÀý×Ó¡£
 
ÏȽ¨Á¢±í
CREATE TABLE book (
 
id
int(11) NOT NULL auto_increment,
 
num
int(11) default NULL,
 
name varchar(0) default NULL,
 
PRIMARY KEY 
(id),
 
KEY
asd (num)
) ENGINE=InnoDB
 
ÆäÖÐ
num
×ֶμÓÁËË÷Òý
 
È»ºó²åÈëÊý¾Ý£¬ÔËÐУ¬
insert into bo


Ïà¹ØÎĵµ£º

תmysql×Ö·û¼¯¼°±àÂëת»»Ñ§Ï°Æª


mysql
·þÎñÆ÷ÖÐÓÐÁù¸ö¹Ø¼üλÖÃʹÓÃÁË×Ö·û¼¯µÄ¸ÅÄî,

ËûÃÇÊÇ£º

client
¡¢connection
¡¢database
¡¢results
¡¢server,

 
a
¡¢ÆäÖÐclient
ÊÇ¿Í»§¶ËʹÓõÄ×Ö·û¼¯£¬Ï൱ÓÚÍøÒ³ÖеÄ×Ö·û¼¯ÉèÖÃÈçÏÂ

<
meta http-equiv
=
"Content-Type"
content
=
"text/html;charset=utf ......

ÈÃmysql Äܹ»Ô¶³ÌÁ¬½Ó

mysql error number 2003   
Can't connect to MySQL server xxx.xxx.xxx.xxx (10061)
ÔÚubuntu 9.04ÖÐĬÈÏ°²×°ÁËmysql£¬Ä¬ÈÏÖ»Äܱ¾µØ·ÃÎÊ£¬googleÁËһϣº
²ÉÓÃ
µÇ¼µ½MySQL·þÎñÆ÷¶Ë£¬ÔÚmysql¿âÏÂÖ´ÐÐ
grant all on *.* to 'remote'@'172.16.21.39' identified by 'password';
¼´¿É
Èç¹ûÒªÉèÖÃΪ ......

mysqlÖÐʱ¼ä²éѯº¯Êý£¨°üÀ¨Ê±¼ä´Á£©

ÕâЩº¯Êý¶¼ÊÇMySQL×Ô´øµÄ£¬¿ÉÒÔÖ±½ÓʹÓÃÔÚPHPдµÄMySQL²éѯÓï¾äÖÐŶ
1-CURDATE()»òCURRENT_DATE()ºÍCURTIME()»òCURRENT_TIME()
ÕâÁ½¸öº¯ÊýÊDZȽϳ£Óõ½µÄ£¬¹ËÃû˼Ò壬µÚÒ»¸ö·µ»Øµ±Ç°ÈÕÆÚ£¬µÚ¶þ¸ö·µ»Øµ±Ç°Ê±¼ä
¿ÉÒÔÔÚMySQL¿Í»§¶Ë»òÕßPHPÓï¾äÀïд"SELECT CURDATE(),CURTIME()"²é¿´Ïà¹ØÐÅÏ¢.
»¹ÓÐÒ»¸öºÜÖØÒªµÄº¯ ......

MySql±Ê¼Ç02

Ò»¡¢Á¬½ÓMYSQL
¡¡¡¡¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £­pÓû§ÃÜÂë
¡¡¡¡1¡¢Àý1£ºÁ¬½Óµ½±¾»úÉϵÄMYSQL¡£
¡¡¡¡Ê×ÏÈÔÚ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼ mysqlbin£¬ÔÙ¼üÈëÃüÁîmysql -uroot -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂ룬Èç¹û¸Õ°²×°ºÃMYSQL£¬³¬¼¶Óû§rootÊÇûÓÐÃÜÂëµÄ£¬¹ÊÖ±½Ó»Ø³µ¼´¿É½øÈëµ½MYSQLÖÐÁË£¬MYSQLµÄÌáʾ·ûÊÇ£ºmysql>
¡¡¡ ......

¿ìËÙµ¼³öµ¼ÈëmysqlÃüÁî


mysqldump -u root -p -e --max_allowed_packet=1048576 --net_buffer_length=16384 msiptv>c:\thedump.sql
ÎÊÌ⣺ÔÚʹÓÃmysql¹ý³ÌÖб¸·ÝÊý¾Ý£¬Ò»°ã¶¼ÊDZ»·Ö³ÉsqlÓï¾äÎı¾£¬µ«mysqldumpÃüÁîĬÈÏÊǷdz£»úеµØ´¦ÀíÓï¾äµÄ×éÖ¯¡£µ¼ÖÂÖØе¼ÈëµÄʱºòЧÂÊÌ«µÍ¡£±ÈÈç10ÍòÌõÊý¾Ý¾ÍÒªÖ´ÐÐ10Íò´ÎµÄsqlÓï¾ä£¬ºÄʱ̫¶à¡£
Ô­Àí£º ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ