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

MYSQL×Ô´ø¹¤¾ßQuery ProfilerʹÓÃ

Query ProfilerÊÇMYSQL×Ô´øµÄÒ»ÖÖqueryÕï¶Ï·ÖÎö¹¤¾ß£¬Í¨¹ýËü¿ÉÒÔ·ÖÎö³öÒ»ÌõSQLÓï¾äµÄÐÔÄÜÆ¿¾±ÔÚʲôµØ·½¡£Í¨³£ÎÒÃÇÊÇʹÓõÄexplain,ÒÔ¼°slow query log¶¼ÎÞ·¨×öµ½¾«È··ÖÎö£¬µ«ÊÇQuery ProfilerÈ´¿ÉÒÔ¶¨Î»³öÒ»ÌõSQLÓï¾äÖ´Ðеĸ÷ÖÖ×ÊÔ´ÏûºÄÇé¿ö£¬±ÈÈçCPU£¬IOµÈ£¬ÒÔ¼°¸ÃSQLÖ´ÐÐËùºÄ·ÑµÄʱ¼äµÈ¡£²»¹ý¸Ã¹¤¾ßÖ»ÓÐÔÚMYSQL 5.0.37ÒÔ¼°ÒÔÉÏ°æ±¾ÖвÅÓÐʵÏÖ¡£
ĬÈϵÄÇé¿öÏ£¬MYSQLµÄ¸Ã¹¦ÄÜûÓдò¿ª£¬ÐèÒª×Ô¼ºÊÖ¶¯Æô¶¯¡£¿ÉÒÔͨ¹ýÈçÏ·½·¨²é¿´µ±Ç°mysql·þÎñÆ÷ÊÇ·ñ¿ªÆôÁ˸ù¦ÄÜ¡£
mysql> show variables like '%profiling%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| profiling              | OFF   |
| profiling_history_size | 15    |
+------------------------+-------+
2 rows in set (0.03 sec)
profiling²ÎÊýֵΪOFF£¬ËµÃ÷ûÓдò¿ª¸Ã¹¦ÄÜ¡£
profiling_history_size²ÎÊýֵΪ15±íʾ£¬¼Ç¼×î½ü15´ÎµÄ²éѯÀúÊ·¡£¸ÃÖµ¿ÉÒÔÐ޸ġ£
ϱß˵˵ÈçºÎ´ò¿ªprofiling¹¦ÄÜ£º
MYSQLÌáʾ·ûÏÂÖ´ÐÐÈçÏÂÃüÁ
mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)
È»ºóÔٴμìÑéÏÂÖ´ÐеÄЧ¹û£º
mysql> show variables like '%profiling%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| profiling              | ON    |
| profiling_history_size | 15    |
+------------------------+-------+
2 rows in set (0.00 sec)
profilingֵΪON˵Ã÷ÒѾ­Æô¶¯¸Ã¹¦ÄÜ¡£
ϱß˵˵ÈçºÎʹÓÃshow profiles;
1.Ê×ÏÈÖ´ÐÐÒ»²éѯÓï¾ä£º
mysql> select * from user;
+------+-----------+
| id   | name      |
+------+-----------+
|   22 | abc       |
|  223 | dabc      |
| 2232 | dddabc    |
|   45 | asdsagd   |
|   23 |


Ïà¹ØÎĵµ£º

ͬ²½Æô¶¯Ñ¡Ïî(mysql ͬ²½)

²»¹ÜÊÇmaster»¹ÊÇslave£¬¶¼ÒªÉ趨 server-id Ñ¡ÏîÀ´È·¶¨Ê¹ËüÃǶ¼Óи÷×ÔΨһµÄͬ²½ID¡£±ØÐëÑ¡Ôñ 1 µ½ 2^32-1 Ö®¼äµÄÕýÕûÊý¡£ÀýÈ磺 server-id=3¡£
¹ØÓÚmaster·þÎñÆ÷ÉÏ¿ÉÓÃÓÚ¿ØÖƶþ½øÖÆÈÕÖ¾¼Ç¼µÄÑ¡ÏîÏêϸÃèÊöÇë¿´"5.9.4 The Binary Log"¡£
ϱíÃèÊöÁËslaveͬ²½¿ÉÓõÄÑ¡Ï¿ÉÒÔÔÚÃüÁîÐлòÕßÅäÖÃÎļþÖÐÉ趨ËüÃÇ¡£
һЩslav ......

mysql Ïà¹ØÅäÖÃ

mysqlÖв»Çø·Ö´óСд£º
LinuxÖÐMySQLµÄÅäÖÃÎļþÖÐ(/etc/my.cnf)£¬ÊÇûÓÐlower_case_table_names=1ÕâÐеġ£
ÔÚWindows°²×°µÄMySQLµÄÅäÖÃÎļþÖÐ(my.ini)£¬ÊÇÓÐlower_case_table_names=1ÕâÐеġ£
lower_case_table_names=1µÄÓÃ;ÊÇÈÃMySQLʵÏÖ²»Çø·Ö´óСд
mysqlÖÐÔÊÐíÆäËû»úÆ÷·ÃÎÊ£º
mysql> use mysql;
Õâ¾ä»°µÄÒâ˼ ......

mysql µ¼Êý¾Ý¿âÃüÁî

mysql µ¼Êý¾Ý¿âÃüÁî
mysqlÃüÁîµ¼Êý¾Ý¿â½Å±¾¡£
mysql>create database databaseName
mysql>use yourDatabase
mysql>source d:yourSql.sql
=========================
1.mysql -u root -p Javascript:tagshow(event, '%CA%FD%BE%DD%BF%E2');" href="http://www.xland.com.cn/article/74/76/0704/Javascript:;" ......

Mysql my.ini ÅäÖÃÎļþÏê½â

Mysql my.ini ÅäÖÃÎļþÏê½â
#BEGIN CONFIG INFO
#DESCR: 4GB RAM, ֻʹÓÃInnoDB, ACID, ÉÙÁ¿µÄÁ¬½Ó, ¶ÓÁиºÔØ´ó
#TYPE: SYSTEM
#END CONFIG INFO
#
# ´ËmysqlÅäÖÃÎļþÀý×ÓÕë¶Ô4GÄÚ´æ
# Ö÷ҪʹÓÃINNODB
#´¦Àí¸´ÔÓ¶ÓÁв¢ÇÒÁ¬½ÓÊýÁ¿½ÏÉÙµÄmysql·þÎñÆ÷
#
# ½«´ËÎļþ¸´ÖƵ½/etc/my.cnf ×÷Ϊȫ¾ÖÉèÖÃ,
# mysql-data-d ......

MySQLѧϰ(5)IN,GRANT,MD5,EXISTS

1.INµÄÓ÷¨
IN(value,value1,...) valuesµÄ¸öÊý¸úmax_allowed_packetÏà¹Ø£¬SELECT 2 IN (2,4,'STRING');
NOT IN(value,..)ºÍINÓï·¨Ò»Ñù¡£
2.IF NOT EXISTS
CREATE ... IF NOT EXISTS stm; ...¿ÉÒÔʹDATABASE,TABLE,EVENT¡£ÈçCREATE TABLE IF NOT EXISTS t(id INT); 
3.MD5,MySQLÊý¾Ý¿âÌṩÁËmd5¼ÓÃܹ¦Ä ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ