MySQLʹÓü¼ÇÉÐĵÃ
2009Äê10ÔÂ30ÈÕ ÐÇÆÚÎå 22:53
ÓÃmysql
ÄÚÖú¯Êýת»»ipµØÖ·ºÍÊý×Ö
ÀûÓÃÁ½¸öÄÚÖú¯Êý
inet_aton:½«ipµØַת»»³ÉÊý×ÖÐÍ
inet_ntoa:½«Êý×ÖÐÍת»»³ÉipµØÖ·
³ä·ÖÀûÓÃmysqlÄÚÖõÄ
format
º¯Êý
ÓÈÆäÊÇÔÚ´¦Àí×Ö·û¸ñʽµÄʱºò,ÀýÈ罫12345ת»»³É12,345ÕâÑùµÄ,Ö»ÒªÓÃ:format(12345,0)¼´¿É,Èç¹ûÓÃformat(12345,2)ÔòÏÔʾµÄÊÇ12,345.00ÁË...
ÀûÓÃmysqlµÄÄÚÖú¯Êý´¦Àíʱ¼ä´ÁÎÊÌâ
eg : select from_UNIXTIME(UNIX_TIMESTAMP(),'%Y %D %M %h:%i:%s %x');
½á¹û: 2004 3rd August 03:35:48 2004
ÀûÓÃmysql_convert_table_formatת»»±íÀàÐÍ
ÐèÒªDBIºÍDBDµÄmysqlÏà¹ØÄ£¿éÖ§³Ö²ÅÄÜÓÃ,Àý×Ó:
mysql_convert_table_format --user=root --
password
='xx' --type=myisam test yejr
ÐÞ¸Ämysql±íÖеÄ×Ö¶ÎÃû
alter
table
tb_name change old_col new_col definition...
ÀûÓÃÁÙʱ±äÁ¿
select @var1:=a1+a2 as a_sum,@var2:=b1+b2 as b_sum,@var1+@var2 as total_sum from test_table xxx;
ÓÃ
int
ÀàÐÍ´æ´¢ipµØÖ·
ÔÏÈ´íÎóµÄÈÏΪ±ØÐëÓÃbigint²Å¹»£¬ºóÀ´·¢ÏÖʹÓÃint unsignedÀàÐ;Í×ã¹»ÁË¡£ :)
ÀûÓÃIFº¯Êý¿ìËÙÐÞ¸ÄENUM×Ö¶ÎÖµ
Ò»¸öÀý×Ó£º
update rule
set
enable = if('0' = enable,'1','0') where xxx;
enable ÀàÐÍ£ºenum('0','1') not null default '0'
ÊÂÎñÎÞ·¨Ç¶Ì×
±ÜÃⳤʱ¼äµÄsleepÁ¬½ÓÔì³ÉµÄÁ¬½ÓÊý³¬³öÎÊÌâ
É趨ȫ¾Ö±äÁ¿ wait_timeout ºÍ interactive_timeout Ϊ±È½ÏСµÄÖµ£¬ÀýÈç
10(s)£¬¾ÍÄÜʹÿ¸ösleepÁ¬½ÓÔÚ10sÖ®ºóÈç¹û»¹Ã»Óвéѯ
µÄ»°×Ô¶¯¶Ï¿ª¡£
É趨mysql¿Í»§¶ËµÄÌáʾ·û(prompt)
export MYSQL_PS1="(\\u:\\h:)\\d> "
ÔòÓà mysql -hlocalhost -uroot -pxx db_name µÇ¼ºó£¬Ìáʾ·û±ä³É£º
(root:localhost:)db_name>
ºÃÓÃ°É :), ʱʱ¿Ì¿ÌÌáÐÑÄãÔÚÄĸö·þÎñÆ÷ÉÏ£¬¾¡Á¿±ÜÃâÎó²Ù×÷µÄ·¢Éú
¸üÏêϸµÄÇë²é¿´MySQLÊÖ²á
ÕûÀíMyISAMËéƬ
1.) ¶¨ÆÚÔËÐÐ OPTIMIZE TABLE ÃüÁî¼´¿É
2.) ÓÃmysqldump³öÊý¾Ý£¬È»ºóÖØÐÂ
import
»ØÈ¥£¬Õâ¶Ô´ó±íÀ´ËµÏÔÈ»µÚÒ»ÖÖ·½·¨±È½Ï·½±ã
ÕûÀíInnodbËéƬ
1.) ÔËÐÐNULLÃüÁ ALTER TABLE XXX ENGINE=Innodb;
2.) ͬÉϵÄmysqldump·½·¨
MySQLÈç¹ûÈÏΪ¼ìË÷µÄ¼Ç¼ÊýÁ¿³¬¹ý×ܼǼÊýµÄ30%£¬ÔòÑ¡ÔñÈ«±íɨÃ裬¶ø·ÇʹÓÃË÷Òý
MySQL 5.0.3Ö®ºó,VARCHAR×ֶκóÃæµÄ¿Õ¸ñ¾Í²»ÔÙɾ³ý
Éý¼¶µ½4.1.1»ò¸ü¸ßºó£¬¾ÍºÜÄѽµ¼¶»Øµ½4.0»ò4.1ÁË£¬ÒòΪ InnoDB ʹÓÃÁ˶à¸ö±í¿Õ¼äµÄÔµ¹Ê
MySQL 4.1Ö®ºó£¬MySQL°Ñ
Ïà¹ØÎĵµ£º
select id from message where author_id in (select followed_id from Relation where follower_id=1) order by id desc ºÍ ·Ö±ðÖ´ÐÐ $userlist = select followed_id from Relation where follower_id=1 ÔÙ select id from message where author_id in ($userlist) order by id desc ¾¹È»ÓÐÁ½¸öÊýÁ ......
ÓÐ2¸ö²»Í¬µÄ·½·¨Ôö¼ÓÓû§£ºÍ¨¹ýʹÓÃGRANTÓï¾ä»òͨ¹ýÖ±½Ó²Ù×÷MySQLÊÚȨ±í¡£±È½ÏºÃµÄ·½·¨ÊÇʹÓÃGRANTÓï¾ä£¬ÒòΪËûÃÇÊǸü¼òÃ÷²¢ÇÒºÃÏñ´íÎóÉÙЩ¡£
ÏÂÃæµÄÀý×ÓÏÔʾ³öÈçºÎʹÓÃMySQL¿Í»§°²×°ÐÂÓû§¡£ÕâЩÀý×Ó¼Ù¶¨È¨ÏÞÒÑȱʡ±»°²×°¡£ÕâÒâζ
×ÅΪÁ˸ı䣬Äã±ØÐëÔÚMySQLÕýÔÚÔËÐÐͬһ̨»úÆ÷ÉÏ£¬Äã±ØÐë×÷ΪMySQL
ro ......
ÓÐʱºònginx£¬apache£¬mysql£¬php±àÒëÍêÁËÏë¿´¿´±àÒë²ÎÊý¿ÉÒÔÓÃÒÔÏ·½·¨
nginx±àÒë²ÎÊý£º
#/usr/local/nginx/sbin/nginx -V
CODE:
nginx version: nginx/0.6.32
built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42)
configure arguments: --user=www --group=www --prefix=/usr/local/nginx/ --with-http_stub_status_mo ......
°æȨÉùÃ÷£º¿ÉÒÔÈÎÒâתÔØ£¬×ªÔØʱÇëÎñ±ØÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷
http://www.5ilinux.com/lamp01.html
¹Ø¼ü×Ö£ºapache+mysql+php apache mysql php ÅäÖà lamp ·þÎñÆ÷ web
Linux+Apache+Mysql+PHPµäÐÍÅäÖÃ
µ÷ÊÔ»·¾³£ºRedhat9.0 Apache1.3.29 Mysql3.23.58 PHP4.3.4
LinuxϵͳµÄ°²×°ÎҾͲ»½²Á ......
2009Äê10ÔÂ30ÈÕ ÐÇÆÚÎå 22:53
1, ²é¿´MySQL
·þÎñÆ÷ÅäÖÃÐÅÏ¢
mysql> show variables;
mysql> show variables;
2, ²é¿´MySQL·þÎñÆ÷ÔËÐеĸ÷ÖÖ״ֵ̬
mysql> show global status;
mysql> show global status;
3, Âý²éѯ
mysql> show variables like '%slow%';
+--------------- ......