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»áÁîÄãµÄ²éѯ¸ü¼ÓÓÐЧ¡£
Ïà¹ØÎĵµ£º
Mysql ¹Ø¼ü×Ö-±£Áô×Ö
ÔÚpowerdesignerÉè¼ÆµÄʱºòÓÃÁ˹ؼü×Ö£¬Éú³É³ö´í£¬ºÜ囧¡£¡£¡£
ADD
ALL
ALTER
ANALYZE
AND
AS
ASC
ASENSITIVE
BEFORE
BETWEEN
BIGINT
BINARY
BLOB
BOTH
BY
CALL
CASCADE
CASE
CHANGE
CHAR
CHARACTER
CHECK
COLLATE
COLUMN
CON ......
MySql³£ÓÃÃüÁî
¡¾MySqlÃüÁî´°¿ÚÆô¶¯£ºÇëÖ´ÐÐ\bin\mysql.exe¡¿
1:ʹÓÃSHOWÓï¾äÕÒ³öÔÚ·þÎñÆ÷Éϵ±Ç°´æÔÚʲôÊý¾Ý¿â£º
mysql> SHOW DATABASES;
2:´´½¨Ò»¸öÊý¾Ý¿âMYSQLDATA
mysql> CREATE DATABASE MYSQLDATA;
3:Ñ¡ÔñÄãËù´´½¨µÄÊý¾Ý¿â
mysql> USE MYSQLDATA; (°´»Ø³µ¼ü³öÏÖDatabase changed Ê±Ë ......
linux
ÏÂ mysql
Óû§µÄ¹ÜÀí
ÎÄÕ·ÖÀà:Êý¾Ý¿â
¹Ø¼ü×Ö: linux
mysql
Óû§¹ÜÀí
×Ô´ÓÉÏÔÚredhat Enterprise 5 Öа²×°ÁËMySQL
,Õâ´ÎÀ´Êµ¼ù²Ù×÷Ò»ÏÂMySQL
Óû§µÄ¹ÜÀí£»
Ò»¡¢rootÓû§ÃÜÂëµÄά»¤£º
ÓÉÓÚ°²×°MySQL
Íêºó,MySQL
»á×Ô¶¯Ìṩһ¸ö²»´ø ......
MySQL°æ±¾: Server version: 5.1.44 Source distribution
ÐÞ¸ÄrootÃÜÂë
Èç¹ûûÓÐÃÜÂëʹÓÃÏÂÃæµÄÃüÁî, ½«ÃÜÂëÉèΪ"123456"
$ mysqladmin -u root password 123456
Èç¹ûÓÐÃÜÂëʹÓÃÏÂÃæµÄÃüÁî, ½«ÃÜÂë¸ÄΪ"123456"
$ mysqladmin -u root -p password 123456
Enter password:
Óû§ÕË»§¹ÜÀí
Ìí¼ÓÕË» ......