MySQLµÄfrom_UNIXTIME()ºÍUNIX_TIMESTAMP()º¯ÊýµÄÇø±ð
from_unixtime()ÊÇMySQLÀïµÄʱ¼äº¯Êý
dateΪÐèÒª´¦ÀíµÄ²ÎÊý(¸Ã²ÎÊýÊÇUnix ʱ¼ä´Á),¿ÉÒÔÊÇ×Ö¶ÎÃû,Ò²¿ÉÒÔÖ±½ÓÊÇUnix ʱ¼ä´Á×Ö·û´®
ºóÃæµÄ '%Y%m%d' Ö÷ÒªÊǽ«·µ»ØÖµ¸ñʽ»¯
ÀýÈç:
mysql>SELECT from_UNIXTIME( 1249488000, '%Y%m%d' )
->20071120
mysql>SELECT from_UNIXTIME( 1249488000, '%YÄê%mÔÂ%d' )
->2007Äê11ÔÂ20
UNIX_TIMESTAMP()ÊÇÓëÖ®Ïà¶ÔÕýºÃÏà·´µÄʱ¼äº¯Êý
UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date)
¡¡¡¡ÈôÎÞ²ÎÊýµ÷Óã¬Ôò·µ»ØÒ»¸ö Unix timestamp ('1970-01-01 00:00:00' GMT Ö®ºóµÄÃëÊý) ×÷ΪÎÞ·ûºÅÕûÊý¡£ÈôÓÃdate À´µ÷Óà UNIX_TIMESTAMP()£¬Ëü»á½«²ÎÊýÖµÒÔ'1970-01-01 00:00:00' GMTºóµÄÃëÊýµÄÐÎʽ·µ»Ø¡£date ¿ÉÒÔÊÇÒ»¸ö DATE ×Ö·û´®¡¢Ò»¸ö DATETIME×Ö·û´®¡¢Ò»¸ö TIMESTAMP»òÒ»¸öµ±µØÊ±¼äµÄYYMMDD »òYYYMMDD¸ñʽµÄÊý×Ö¡£
ÀýÈç:
mysql> SELECT UNIX_TIMESTAMP() ; £¨Ö´ÐÐʹµÃʱ¼ä:2009-08-06 10:10:40£©
->1249524739
mysql> SELECT UNIX_TIMESTAMP('2009-08-06') ;
->1249488000
ÈçºÎÔÚ²»Í¬±à³ÌÓïÑÔÖлñÈ¡ÏÖÔÚµÄUnixʱ¼ä´Á(Unix timestamp)£¿
Java
time
JavaScript
Math.round(new Date().getTime()/1000)
getTime()·µ»ØÊýÖµµÄµ¥Î»ÊǺÁÃë
Microsoft .NET / C#
epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000
MySQL
SELECT unix_timestamp(now())
Perl
time
PHP
time()
PostgreSQL
SELECT extract(epoch from now())
Python
ÏÈ import time È»ºó time.time()
Ruby
»ñÈ¡Unixʱ¼ä´Á£ºTime.now »ò Time.new
ÏÔʾUnixʱ¼ä´Á£ºTime.now.to_i
SQL Server
SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE())
Unix / Linux
date +%s
VBScript / ASP
DateDiff("s", "01/01/1970 00:00:00", Now())
ÆäËû²Ù×÷ϵͳ
(Èç¹ûPerl±»°²×°ÔÚϵͳÖÐ)
ÃüÁîÐÐ״̬£ºperl -e "print time"
ÈçºÎÔÚ²»Í¬±à³ÌÓïÑÔÖÐʵÏÖUnixʱ¼ä´Á(Unix timestamp) → ÆÕͨʱ¼ä£¿
Java
String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date(Unix timestamp * 1000))
JavaScript
ÏÈ var unixTimestamp = new Date(Unix timestamp * 1000) È»ºó commonTime = unixTimestamp.toLocaleString()
Linux
date -d @Unix timestamp
MySQL
from_unixtime(Unix timestamp)
Perl
ÏÈ my $time = Unix tim
Ïà¹ØÎĵµ£º
ÔËÐгÌÐò¿ÉÄܻᱨ´í£ºCan’t connect to local MySQL Server through socket ‘/tmp/mysql.sock’
Õâ¸ö´íÎóµÄÌáʾÊÇ˵£¬²»ÄÜͨ¹ý’/tmp/mysql.sock’Á¬½Óµ½·þÎñÆ÷¡£Mysql.sockÊÇ´´½¨Óëmysqld·þÎñÆ÷Ïà¹ØµÄMySQLͨÐŶ˵ãËùʹÓõÄÌ×½Ó×Ö¡£¶øPHP±ê×¼ÅäÖÃÕýÊÇͨ¹ý’/tmp/mysql.sock’À´Á¬½Ó ......
ÀýÈ磬MySQLĬÈϵÄÊý¾ÝÎļþ´æ´¢Ä¿Â¼Îª/var/lib/mysql¡£¼ÙÈçÒª°ÑÄ¿Â¼ÒÆµ½/home/dataÏÂÐèÒª½øÐÐÏÂÃæ¼¸²½£º
1¡¢homeĿ¼Ï½¨Á¢dataĿ¼
cd /home
mkdir data
2¡¢°ÑMySQL·þÎñ½ø³ÌÍ£µô£º
......
http://blog.csdn.net/zhangwenzhe/archive/2008/05/22/2470529.aspx
ÔÚ
MySQL 3.23.15
°æ±¾Ö®ºó
,MySQL
ÌṩÁËÊý¾Ý¿â¸´ÖƵŦÄÜ
,
¿ÉÒÔʵÏÖÁ½¸öÊý¾Ý¿âʵʱͬ²½
,
ÔöÇ¿ÁË
MySQL
Êý¾Ý¿âµÄÎȶ¨ÐÔ£¬¶øÇÒ¿ÉÒÔÔÚÆóÒµ¼¶Ó¦ÓõÄÊý¾Ý¿â²ãʵÏÖ
Cluster
£¬²»½ö´ó´óÌá¸ßÁË
mysql
µÄ°²È«ÐÔ£¬Í¬Ê±»¹¼õÇáÁË
DBA
´óÁ¿µÄ¹¤× ......
Äã¿ÉÒÔ´´½¨Ò»¸öÎı¾Îļþ“pet.txt”£¬Ã¿Ðаüº¬Ò»¸ö¼Ç¼£¬Óö¨Î»·û(tab)°ÑÖµ·Ö¿ª£¬²¢ÇÒÒÔCREATE TABLEÓï¾äÖÐÁгöµÄÁдÎÐò¸ø³ö¡£¶ÔÓÚ¶ªÊ§µÄÖµ(ÀýÈçδ֪µÄÐԱ𣬻òÈÔÈ»»î×ŵ͝ÎïµÄËÀÍöÈÕÆÚ)£¬Äã¿ÉÒÔʹÓÃNULLÖµ¡£ÎªÁËÔÚÄãµÄÎı¾ÎļþÖбíʾÕâЩÄÚÈÝ£¬
ʹÓÃ\N£¨·´Ð±Ïߣ¬×ÖĸN£©¡£ÀýÈ磬WhistlerÄñµÄ¼Ç¼ӦΪ(ÕâÀïÖµÖ® ......
MYSQL Castº¯Êý ÀàÐÍת»»
BINARY
BINARY²Ù×÷·û½«ºóÃæµÄ×Ö·û´®Å׸øÒ»¸ö¶þ½øÖÆ×Ö·û´®¡£ÕâÊÇÒ»ÖÖ¼òµ¥µÄ·½Ê½À´´ÙʹÖð×Ö½Ú¶ø²»ÊÇÖð×Ö·ûµÄ½øÐÐÁбȽϡ£ÕâʹµÃ±È½ÏÇø·Ö´óСд£¬¼´Ê¹¸ÃÁв»±»¶¨ÒåΪ BINARY»ò BLOB¡£BINARYÒ²»á²úÉú½áβ¿Õ°×£¬´Ó¶ø¸ü¼ÓÏÔÑÛ¡£
mysql> SELECT 'a' = 'A';
-> 1
mysql> SELECT BINARY ' ......