MySQLÔÓ
MySQLµÄtimestampÀàÐÍ×Ô¶¯¸üÐÂÎÊÌâ
½ñÌ콨ÁËÒ»¸ö±í£¬ÀïÃæÓÐÒ»¸öÁÐÊÇtimestampÀàÐÍ£¬ÎÒ±¾ÒâÊÇÔÚÊý¾Ý¸üÐÂʱ£¬Õâ¸ö×ֶεÄʱ¼äÄÜ×Ô¶¯¸üС£ÆñÖª¶ÔÕâ¸öÀàÐ͵ÄÖµ»¹²»ÉõÁ˽⣬µ¼Ö³ö´í¡£·¢ÏÖÕâ¸ö×Ö¶ÎÖ»ÊÇÔÚÕâÐÐÊý¾Ý½¨Á¢µÄʱºòÓÐÖµ£¬ÔÚ¸üеÄÈ´Îޱ仯¡£
²éÕÒ×ÊÁÏ£¬·¢ÏÖÊÇÎÒ½¨±íµÄÓï¾äÓÐÎÊÌ⣺
ÒÔÏÂÊÇ´úÂëƬ¶Î£º
CREATE TABLE `test` (
`t1` timestamp NOT NULL default CURRENT_TIMESTAMP,
`ww` varchar(5) NOT NULL
) ENGINE=MyISAM ;
¶øʵ¼ÊÉÏ£¬ÒÔÏÂÁ½¸ö½¨±íÓï¾äµÄЧ¹ûÊÇÒ»ÑùµÄ£º
ÒÔÏÂÊÇ´úÂëƬ¶Î£º
CREATE TABLE `test` (
`t1` TIMESTAMP NOT NULL ,
`ww` VARCHAR( 5 ) NOT NULL
) ENGINE = MYISAMCREATE TABLE `test` (
`t1` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ww` varchar(5) NOT NULL
) ENGINE=MyISAM ;
±È½Ï֮ϣ¬ÎÒµÄÓï¾äÉÙÁË“on update CURRENT_TIMESTAMP”»ò¶àÁË“default CURRENT_TIMESTAMP”¡£Èç´ËÒ»À´£¬Õâ¸ötimestamp×Ö¶ÎÖ»ÊÇÔÚÊý¾ÝinsertµÄʱ¼ä½¨Á¢Ê±¼ä£¬¶øupdateʱ¾Í²»»áÓб仯ÁË¡£µ±È»£¬Èç¹ûÄã¾ÍÊÇÏë´ïµ½Õâ¸öÄ¿µÄµ¹Ò²ÎÞËùν¡£
²éÕÒÓ¢ÎÄÊֲᣨhttp://dev.mysql.com/doc/refman/5.1/en/timestamp.html£©£¬µÃµ½¸üÏêϸµÄ½â˵£¬·ÒëÈçÏ£º
———————————–·Ò뿪ʼ——————————–
ÔÚCREATE TABLEÓï¾äÖУ¬µÚ1¸öTIMESTAMPÁпÉÒÔÓÃÏÂÃæµÄÈκÎÒ»ÖÖ·½Ê½ÉùÃ÷£º
1£º Èç¹û¶¨ÒåʱDEFAULT CURRENT_TIMESTAMPºÍON UPDATE CURRENT_TIMESTAMP×Ӿ䶼ÓУ¬ÁÐֵΪĬÈÏʹÓõ±Ç°µÄʱ¼ä´Á£¬²¢ÇÒ×Ô¶¯¸üС£
2£º Èç¹û²»Ê¹ÓÃDEFAULT»òON UPDATE×Ӿ䣬ÄÇôËüµÈͬÓÚDEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP¡£
3£º Èç¹ûÖ»ÓÐDEFAULT CURRENT_TIMESTAMP×Ӿ䣬¶øûÓÐON UPDATE×Ӿ䣬ÁÐֵĬÈÏΪµ±Ç°Ê±¼ä´Áµ«²»×Ô¶¯¸üС£
4£º Èç¹ûûÓÃDEFAULT×Ӿ䣬µ«ÓÐON UPDATE CURRENT_TIMESTAMP×Ӿ䣬ÁÐĬÈÏΪ0²¢×Ô¶¯¸üС£
5£º Èç¹ûÓÐÒ»¸ö³£Á¿ÖµDEFAULT£¬¸ÃÁлáÓÐÒ»¸öĬÈÏÖ
Ïà¹ØÎĵµ£º
Ê×ÏÈÍ£Ö¹MySQL·þÎñ£ºsudo /etc/init.d/mysql stop
È»ºó±à¼MySQLÅäÖÃÎļþ£ºsudo gedit /etc/mysql/my.cnf
ÔÚmy.cnfÎļþÖеÄ[client]¶ÎÏÂÃæ¼ÓÈë
default-character-set=utf8
[mysqld_safe]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysql]
default-character-set=utf8
ÖØÐÂÆô¶¯MySQL·þÎñ ......
linux:
Èç¹û MySQL ÕýÔÚÔËÐУ¬Ê×ÏÈɱ֮£º killall -TERM mysqld¡£
Æô¶¯ MySQL £º/usr/bin/safe_mysqld --skip-grant-tables &
¾Í¿ÉÒÔ²»ÐèÒªÃÜÂë¾Í½øÈë MySQL ÁË¡£
È»ºó¾ÍÊÇ
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges;
ÖØÐÂɱ MySQL £¬ ......
=== ÉÔºóÔÙÕûÀí
mysql
4.0µ½mysql
5.0µÄÊý¾Ýµ¼Èë³öÏÖÂÒÂëµÄ½â¾ö·½°¸
×ÖÌå´óС£º´ó
| ÖÐ
| С
2007-02-08 17:09 -
ÔĶÁ£º485 - ÆÀÂÛ
£º0
×î½ü×ömysql
4.0µ½mysql
5.0µÄÊý¾Ýת»¯¹¤×÷£¬·¢ÏÖÂÒÂë
ÎÞÊý£¬¹Û²©¿ÍÎÞÊýÐĵÃÈçÏ£º
£ªmysql
ÖÐÎÄ亂碼µÄÔÒò
mysql
會³ö現ÖÐÎÄ ......
MySQL+PHP²úÉúÂÒÂëÔÒò£º
¡¡¡¡¡ô MySQLÊý¾Ý¿âĬÈϵıàÂëÊÇutf8,Èç¹ûÕâÖÖ±àÂëÓëÄãµÄPHPÍøÒ³²»Ò»ÖÂ,¿ÉÄܾͻáÔì³ÉMySQLÂÒÂë;
¡¡¡¡¡ô MySQLÖд´½¨±íʱ»áÈÃÄãÑ¡ÔñÒ»ÖÖ±àÂë,Èç¹ûÕâÖÖ±àÂëÓëÄãµÄÍøÒ³±àÂë²»Ò»ÖÂ,Ò²¿ÉÄÜÔì³ÉMySQLÂÒÂë;
¡¡¡¡¡ô MySQL´´½¨±íʱÌí¼Ó×Ö¶ÎÊÇ¿ÉÒÔÑ¡Ôñ±àÂëµÄ,Èç¹ûÕâÖÖ±àÂëÓëÄãµÄÍøÒ³±àÂë²»Ò»ÖÂ,Ò²¿ÉÄÜÔì³É ......