¡¾×ª¡¿mysqlÖÐDATETIME¡¢DATEºÍTIMESTAMPµÄÇø±ð
DATETIME¡¢DATE ºÍ TIMESTAMP ÀàÐÍÊÇÏàËƵġ£±¾ÆªÃèÊöÁËËüÃǵÄÌØÐÔÒÔ¼°ËüÃǵÄÏàËƵãÓ벻ͬµã¡£
DATETIME ÀàÐÍ¿ÉÓÃÓÚÐèҪͬʱ°üº¬ÈÕÆÚºÍʱ¼äÐÅÏ¢µÄÖµ¡£MySQL ÒÔ 'YYYY-MM-DD HH:MM:SS' ¸ñʽ¼ìË÷ÓëÏÔʾ DATETIME ÀàÐÍ¡£Ö§³ÖµÄ·¶Î§ÊÇ '1000-01-01 00:00:00' µ½ '9999-12-31 23:59:59'¡£(“Ö§³Ö”µÄº¬ÒåÊÇ£¬¾¡¹Ü¸üÔçµÄÖµ¿ÉÄܹ¤×÷£¬µ«²»Äܱ£Ö¤ËûÃǾù¿ÉÒÔ¡£)
DATE ÀàÐÍ¿ÉÓÃÓÚÐèÒªÒ»¸öÈÕÆÚÖµ¶ø²»ÐèҪʱ¼ä²¿·Öʱ¡£MySQL ÒÔ 'YYYY-MM-DD' ¸ñʽ¼ìË÷ÓëÏÔʾ DATE Öµ¡£Ö§³ÖµÄ·¶Î§ÊÇ '1000-01-01' µ½ '9999-12-31'¡£
TIMESTAMP ÁÐÀàÐÍÌṩÁËÒ»ÖÖÀàÐÍ£¬Í¨¹ýËüÄã¿ÉÒÔÒÔµ±Ç°²Ù×÷µÄÈÕÆÚºÍʱ¼ä×Ô¶¯µØ±ê¼Ç Insert »òUpdate ²Ù×÷¡£Èç¹ûÒ»ÕűíÖÐÓжà¸ö TIMESTAMP ÁУ¬Ö»ÓеÚÒ»¸ö±»×Ô¶¯¸üС£
“ÍêÕû”TIMESTAMP¸ñʽÊÇ14룬µ«TIMESTAMPÁÐÒ²¿ÉÒÔÓøü¶ÌµÄÏÔʾ³ß´ç´´Ôì
×î³£¼ûµÄÏÔʾ³ß´çÊÇ6¡¢8¡¢12¡¢ºÍ14¡£
Äã¿ÉÒÔÔÚ´´½¨±íʱָ¶¨Ò»¸öÈÎÒâµÄÏÔʾ³ß´ç£¬µ«ÊǶ¨ÒåÁг¤Îª0»ò±È14´ó¾ù»á±»Ç¿Öƶ¨ÒåΪÁг¤14¡£
Áг¤ÔÚ´Ó1¡«13·¶Î§µÄÆæÊýÖµ³ß´ç¾ù±»Ç¿ÖÆΪÏÂÒ»¸ö¸ü´óµÄżÊý¡£
ÁÐÈ磺
¶¨Òå×ֶγ¤¶È Ç¿ÖÆ×ֶ㤶È
TIMESTAMP(0) -> TIMESTAMP(14)
TIMESTAMP(15)-> TIMESTAMP(14)
TIMESTAMP(1) -> TIMESTAMP(2)
TIMESTAMP(5) -> TIMESTAMP(6)
ËùÓеÄTIMESTAMPÁж¼ÓÐͬÑùµÄ´æ´¢´óС£¬
ʹÓñ»Ö¸¶¨µÄʱÆÚʱ¼äÖµµÄÍêÕû¾«¶È£¨14룩´æ´¢ºÏ·¨µÄÖµ²»¿¼ÂÇÏÔʾ³ß´ç¡£
²»ºÏ·¨µÄÈÕÆÚ£¬½«»á±»Ç¿ÖÆΪ0´æ´¢
×Ô¶¯¸üеÚÒ»¸ö TIMESTAMP ÁÐÔÚÏÂÁÐÈκÎÌõ¼þÏ·¢Éú£º
ÁÐֵûÓÐÃ÷È·µØÔÚÒ»¸ö Insert »ò LOAD DATA INFILE Óï¾äÖб»Ö¸¶¨¡£
ÁÐֵûÓÐÃ÷È·µØÔÚÒ»¸ö Update Óï¾äÖб»Ö¸¶¨£¬²¢ÇÒÆäËüµÄһЩÁÐÖµÒÑ·¢Éú¸Ä±ä¡£(×¢Ò⣬µ±Ò»¸ö Update ÉèÖÃÒ»¸öÁÐֵΪËüÔÓÐֵʱ£¬Õ⽫²»»áÒýÆð TIMESTAMP ÁеĸüУ¬ÒòΪ£¬Èç¹ûÄãÉèÖÃÒ»¸öÁÐֵΪËüµ±Ç°ÖµÊ±£¬MySQL ΪÁËЧÂÊΪºöÂÔ¸üС£)
Ã÷È·µØÒÔ NULL ÉèÖà TIMESTAMP ÁС£
µÚÒ»¸öÁÐÒÔÍâÆäËü TIMESTAMP ÁУ¬¿ÉÒÔÉèÖõ½µ±Ç°µÄÈÕÆÚºÍʱ¼ä£¬Ö»Òª½«¸ÃÁи³Öµ NULL »ò NOW()¡£
ÈκΠTIMESTAMP Áоù¿ÉÒÔ±»ÉèÖÃÒ»¸ö²»Í¬ÓÚµ±Ç°²Ù×÷ÈÕÆÚÓëʱ¼äµÄÖµ£¬Õâͨ¹ýΪ¸ÃÁÐÃ÷È·Ö¸¶¨Ò»¸öÄãËùÆÚÍûµÄÖµÀ´ÊµÏÖ¡£ÕâÒ²ÊÊÓÃÓÚµÚÒ»¸ö TIMESTAMP ÁС£Õâ¸öÑ¡ÔñÐÔÊǺÜÓÐÓõģ¬¾ÙÀýÀ´Ëµ£¬µ±ÄãÏ£Íû TIMESTAMP Áб£´æ¸Ã¼Ç¼Ðб»ÐÂÌí¼ÓʱµÄµ±Ç°µÄÈÕÆÚºÍʱ¼ä£¬µ«¸ÃÖµ²»ÔÙ·¢Éú¸Ä±ä£¬ÎÞÂÛÒÔºóÊÇ·ñ¶Ô¸Ã¼Ç¼ÐнøÐйý¸üУº
µ±¸Ã¼Ç¼Ðб»
Ïà¹ØÎĵµ£º
mysqlµÄÅäÖÃÎļþͨ³£ÃüÃûΪmy.cnf,Èç¹û±£´æÔÚĬÈϵÄ/etc/my.cnfĿ¼ÏÂ,ÄÇôÕâÀïÃæµÄÅäÖÃÊÇÈ«¾ÖµÄ,¼È¶Ô´Ë·þÎñÆ÷ÉϵÄËùÓÐmysql·þÎñÆ÷¶¼ÊÇÓÐЧµÄ(Èç¹ûÄãÓÐÔÚЩ·þÎñÆ÷ÉÏ°²×°Á˶à¸ömysql).Èç¹ûÖ»ÊDZ£´æÔÚij¸ömysql·þÎñÆ÷µÄÊý¾ÝĿ¼ÏÂ,ÔòÖ»¶Ô¸Ãmysql·þÎñÆ÷²úÉú×÷ÓÃ.Èç¹ûÊDZ£´æÔÚij¸öÓû§(µ±È»ÊÇmysqlÓû§)µÄhomeĿ¼ÏÂ,ÔòÖ»ÊÇÔÚmy ......
Ò»¡¢IPÐÅÏ¢ÁÐ±í£º
Ãû³Æ IP
LVS-DR-VIP 192.168.50.245
LVS-DR-Master ......
ϵͳ»·¾³£ºrhel5 (×îС»¯°²×°£¬Ö»°²×°vi¹¤¾ß) Äںˣº2.6.18-8.el5 1¡¢ ÏÂÔرàÒë°²×° #cd /usr/local/src/tarbag #wget http://mysql.byungsoo.net/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz //ÏÂÔØ5.1.38 #tar xzvf mysql-5.1.38.tar.gz -C ../software/ #cd ../software/mysql-5.1.38 #./configure --prefix=/usr ......
1.½¨±íʱ¾Í´´½¨×ÔÔöÁУº
create table test
(
id int auto_increment primary key,
name varchar(20) not null,
password varchar(20) not null
);
insert into test values(null,'aa','aa');
insert into test values(null,'bb','bb');
×¢Ò⣺
²åÈëÓï¾äʱ£¬×Ô ......
1£º Can’t connect to [local] MySQL server´íÎó
Ò»¸öMySQL¿Í»§¿ÉÒÔÁ½ÖÖ²»Í¬µÄ·½Ê½Á¬½Ómysqld·þÎñÆ÷£ºUnixÌ×½Ó×Ö£¬Ëüͨ¹ýÔÚÎļþϵͳÖеÄÒ»¸öÎļþ(ȱʡ“/tmp /mysqld.sock”)½øÐÐÁ¬½Ó£»»òTCP/IP£¬Ëüͨ¹ýÒ»¸ö¶Ë¿ÚºÅÁ¬½Ó¡£UnixÌ×½Ó×Ö±ÈTCP/IP¸ü¿ì£¬µ«ÊÇÖ»ÓÐÓÃÔÚÁ¬½Óͬһ̨¼ÆËã»úÉϵķþÎñÆ÷¡£Èç¹ûÄ ......