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

WEB³ÌÐòÔ±ÐèÒªÕÆÎÕµÄÊ®´óMySQLÓÅ»¯¼¼ÇÉ

1.ÓÅ»¯ÄãµÄMySQL²éѯ»º´æ
ÔÚMySQL·þÎñÆ÷ÉϽøÐвéѯ£¬¿ÉÒÔÆôÓøßËÙ²éѯ»º´æ¡£ÈÃÊý¾Ý¿âÒýÇæÔÚºǫ́ÇÄÇĵĴ¦ÀíÊÇÌá¸ßÐÔÄܵÄ×îÓÐЧ·½·¨Ö®Ò»¡£µ±Í¬Ò»¸ö²éѯ±»Ö´Ðжà´Îʱ£¬Èç¹û½á¹ûÊÇ´Ó»º´æÖÐÌáÈ¡£¬ÄÇÊÇÏ൱¿ìµÄ¡£
µ«Ö÷ÒªµÄÎÊÌâÊÇ£¬ËüÊÇÄÇôÈÝÒ×±»Òþ²ØÆðÀ´ÒÔÖÁÓÚÎÒÃÇ´ó¶àÊý³ÌÐòÔ±»áºöÂÔËü¡£ÔÚÓÐЩ´¦ÀíÈÎÎñÖУ¬ÎÒÃÇʵ¼ÊÉÏÊÇ¿ÉÒÔ×èÖ¹²éѯ»º´æ¹¤×÷µÄ¡£
// query cache does NOT work     $r = mysql_query("SELECT username from user WHERE signup_date >= CURDATE()");         // query cache works!     $today = date("Y-m-d");     $r = mysql_query("SELECT username from user WHERE signup_date >= '$today'");     // query cache does NOT work $r = mysql_query("SELECT username from user WHERE signup_date >= CURDATE()");   // query cache works!  $today = date("Y-m-d");  $r = mysql_query("SELECT username from user WHERE signup_date >= '$today'"); 
2.ÓÃEXPLAINʹÄãµÄSELECT²éѯ¸ü¼ÓÇåÎú
ʹÓÃEXPLAIN¹Ø¼ü×ÖÊÇÁíÒ»¸öMySQLÓÅ»¯¼¼ÇÉ£¬¿ÉÒÔÈÃÄãÁ˽âMySQLÕýÔÚ½øÐÐʲôÑùµÄ²éѯ²Ù×÷£¬Õâ¿ÉÒÔ°ïÖúÄã·¢ÏÖÆ¿¾±µÄËùÔÚ£¬²¢ÏÔʾ³ö²éѯ»ò±í½á¹¹ÔÚÄÄÀï³öÁËÎÊÌâ¡£
EXPLAIN²éѯµÄ½á¹û£¬¿ÉÒÔ¸æËßÄãÄÇЩË÷ÒýÕýÔÚ±»ÒýÓ㬱íÊÇÈçºÎ±»É¨ÃèºÍÅÅÐòµÄµÈµÈ¡£
ʵÏÖÒ»¸öSELECT²éѯ£¨×îºÃÊDZȽϸ´ÔÓµÄÒ»¸ö£¬´øjoins·½Ê½µÄ£©£¬ÔÚÀïÃæÌí¼ÓÉÏÄãµÄ¹Ø¼ü´Ê½âÊÍ£¬ÔÚÕâÀïÎÒÃÇ¿ÉÒÔʹÓÃphpMyAdmin£¬Ëû»á¸æËßÄã±íÖеĽá¹û¡£¾ÙÀýÀ´Ëµ£¬¼ÙÈçµ±ÎÒÔÚÖ´ÐÐjoinsʱ£¬ÕýÍü¼ÇÍùÒ»¸öË÷ÒýÖÐÌí¼ÓÁУ¬EXPLAINÄÜ°ïÖúÎÒÕÒµ½ÎÊÌâµÄËùÔÚ¡£
Ìí¼ÓË÷Òýµ½group_id fieldºó

3.ÀûÓÃLIMIT 1È¡µÃΨһÐÐ
ÓÐʱ£¬µ±ÄãÒª²éѯһÕűíÊÇ£¬ÄãÖªµÀ×Ô¼ºÖ»ÐèÒª¿´Ò»ÐС£Äã¿ÉÄÜ»áÈ¥µÄÒ»ÌõÊ®·Ö¶ÀÌصļǼ£¬»òÕßÖ»ÊǸպüì²éÁËÈκδæÔڵļǼÊý£¬ËûÃǶ¼Âú×ãÁËÄãµÄWHERE×Ӿ䡣
ÔÚÕâÖÖÇé¿öÏ£¬Ôö¼ÓÒ»¸öLIMIT 1»áÁîÄãµÄ²éѯ¸ü¼ÓÓÐЧ¡£


Ïà¹ØÎĵµ£º

linuxÏ mysqlÓû§µÄ¹ÜÀí

linux
ÏÂ mysql
Óû§µÄ¹ÜÀí
ÎÄÕ·ÖÀà:Êý¾Ý¿â
¹Ø¼ü×Ö: linux
mysql
Óû§¹ÜÀí

×Ô´ÓÉÏÔÚredhat Enterprise 5 Öа²×°ÁËMySQL
,Õâ´ÎÀ´Êµ¼ù²Ù×÷Ò»ÏÂMySQL
Óû§µÄ¹ÜÀí£»
 Ò»¡¢rootÓû§ÃÜÂëµÄά»¤£º
       ÓÉÓÚ°²×°MySQL
Íêºó,MySQL
»á×Ô¶¯Ìṩһ¸ö²»´ø ......

MySQL Basic Knowledge

MySQL°æ±¾: Server version: 5.1.44 Source distribution
ÐÞ¸ÄrootÃÜÂë
Èç¹ûûÓÐÃÜÂëʹÓÃÏÂÃæµÄÃüÁî, ½«ÃÜÂëÉèΪ"123456"
$ mysqladmin -u root password 123456
Èç¹ûÓÐÃÜÂëʹÓÃÏÂÃæµÄÃüÁî, ½«ÃÜÂë¸ÄΪ"123456"
$ mysqladmin -u root -p password 123456
Enter password:
Óû§ÕË»§¹ÜÀí
Ìí¼ÓÕË» ......

mysql replication


<!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;
mso-font-alt:"Courier New";
mso-font-charset:0;
mso-generic-font-family:modern;
mso-font-format:other;
mso-font-pitch:fixed;
mso-font-signature:3 0 0 0 1 0;}
@font-face
{f ......

ubuntu MySQL°²×°Ö¸ÄÏ

°²×° MySQL£¬¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÏÂÁÐÃüÁ
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql
// °²×°php5-mysql Êǽ«phpºÍmysqlÁ¬½ÓÆðÀ´
Ò»µ©°²×°Íê³É£¬MySQL ·þÎñÆ÷Ó¦¸Ã×Ô¶¯Æô¶¯¡£Äú¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÒÔÏÂÃüÁîÀ´¼ì²é MySQL ·þÎñÆ÷ÊÇ·ñÕýÔÚÔËÐУº
s ......

MysqlÖÐcount(*),DISTINCTµÄʹÓ÷½·¨ºÍЧÂÊÑо¿

ÔÚ´¦ÀíÒ»¸ö´óÊý¾ÝÁ¿Êý¾Ý¿âµÄʱºò
ͻȻ·¢ÏÖmysql¶ÔÓÚcount(*)µÄ²»Í¬´¦Àí»áÔì³É²»Í¬µÄ½á¹û
±ÈÈçÖ´ÐÐ
SELECT count(*) from tablename
¼´Ê¹¶ÔÓÚǧÍò¼¶±ðµÄÊý¾ÝmysqlÒ²Äܷdz£Ñ¸Ëٵķµ»Ø½á¹û
¶ø¶ÔÓÚ
SELECT count(*) from tablename WHERE…..
mysqlµÄ²éѯʱ¼ä¿ªÊ¼ÅÊÉý
×Ðϸ²éÔÄÀÛÏÂÊÖ²á,·¢ÏÖµ±Ã»ÓÐWHEREÓï¾ä¶ÔÓÚÕ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ