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

MysqlÓÅ»¯¼¼ÇÉ

×ܽáÁËһЩMySQLÓÅ»¯·½ÃæµÄ¼¼ÇÉ
Ò». Æô¶¯²ÎÊýÓÅ»¯
ÐÞ¸Ä my.cnf (»òÕßmy.ini)£¬¼ÓÈë/ÐÞ¸ÄÒÔϼ¸ÐÐ
#É趨»º´æµÄÁ¬½ÓÊý,½ÚÊ¡Á¬½ÓʱµÄ¿ªÏú
back_log = 64
#½ûÓÃÎļþϵͳÍⲿËø
external-locking = 0
#½ûÓÃBDB,Èç¹ûÄãȷʵ²»ÐèÒªµÄ»°,innodbÒ²ÊÇÈç´Ë
skip-bdb
#Ë÷Òý»º³å,Èç¹ûÊÇרÓõÄÊý¾Ý¿â·þÎñÆ÷,¿ÉÒÔÉèÖøߴï·þÎñÆ÷ÄÚ´æµÄÒ»°ë,Èç¹û²»ÊÇרÓõÄ,
#»¹ÊÇÉèÖõõÍÒ»µã
key_buffer = 512M
#»º´æÊý¾Ý±íÊýÁ¿,Èç¹ûÄÚ´æ½Ï´ó,¿ÉÒÔÉèÖÃÉÔ΢¸ßÒ»µã,·ñÔò»¹ÊÇÉèÖõÍÒ»µã
#ÉèÖÃÕâ¸ö²ÎÊý¿ÉÒԲμûϵͳ״̬ÖÐµÄ open_tables(±íʾµ±Ç°´ò¿ªµÄÊý¾Ý±í×ÜÊý)
#ºÍ opened_tables(±íʾËùÓдò¿ªµÄÊý¾Ý±í×ÜÊý)
table_cache = 128
#½ûÓÃdns½âÎö,Èç¹ûÄãµÄÊÚȨÐÅÏ¢ÖвÉÓÃdnsÊÚȨ·½Ê½ÁË,¾Í²»ÄÜÆôÓøÃÑ¡Ïî
skip-name-resolve
#¼Ç¼Âý²éѯºÍûÓÐʹÓÃË÷ÒýµÄ²éѯ,±ãÓÚ°ïÖú·ÖÎöÎÊÌâËùÔÚ
long_query_time = 1
log-slow-queries = /usr/local/mysql/data/slow.log
log-queries-not-using-indexes
ÆäËû²ÎÊýÖîÈç sort_buffer_size,net_buffer_length,read_buffer_size,read_rnd_buffer_size,myisam_sort_buffer_size,
thread_cache_size,query_cache_size,max_binlog_cache_size µÈÇë²éѯMySQLÊÖ²á,È»ºó×ö³öºÏÊʵĵ÷Õû.
¶þ. ÆäËûСTIPS
* Õë¶ÔInnodb±í,¾¡Á¿²»Ö´ÐÐ SELECT COUNT(*) Óï¾ä,ÒòΪInnodb±íûÓÐÀàËÆMyISAMÄÇÑùµÄÄÚ²¿¼ÆÊýÆ÷À´¼Ç¼±í¼Ç¼×ÜÁ¿,Ö´ÐÐÕâ¸ö²Ù×÷½«»áÈ«±íɨÃè,ËٶȺÜÂý.
* ¾¡Á¿Ê¹ÓÃMyISAM±í,³ý·Ç±ØÐëʹÓÃÆäËûÀàÐÍ,ÒòΪMyISAMÀàÐ͵Ä×ÜÌå¶ÁдЧÂÊÊÇÏ൱¸ßµÄ,ȱµãÊÇ±í¼¶Ëø,¶ø²»ÊÇÐÐ/Ò³¼¶Ëø.
* ÉÆÓà EXPLAINÀ´°ïÖúÄã·ÖÎö²éѯÓÅ»¯Çé¿ö
* Èç¹ûÐèÒª¶ÔÒ»¸ö½Ï´óµÄÇÒ²¢·¢¶Áд½Ï¶àµÄÊý¾Ý±í×ö GROUP BY µÈͳ¼Æ²Ù×÷,½¨ÒéʹÓÃÕªÒª±íÀ´´æ´¢Í³¼ÆÐÅÏ¢,¶¨ÆÚ¸üÐÂͳ¼Æ±í,Õâ¿ÉÄÜ»ñµÃºÜ´óµÄÐÔÄܸÄÉÆ.
* ²éѯʱÈç¹ûÓÐ ORDER BY·Ö¾äµÄ»°,×¢ÒâÈÃËüµÄ×Ö¶Î˳ÐòºÍË÷Òý×Ö¶Î˳Ðò¶ÔÓ¦,ÕâÑùÄܼӿìÅÅÐòËÙ¶È
* Èç¹ûÓÐÒ»¸ö¶à×Ö¶ÎË÷Òý,Ôò²éѯʱ,±ØÐë°´ÕÕË÷Òý˳ÐòÀ´Ê¹ÓÃ,·ñÔò¸ÃË÷Òý²»»áÓõ½.ÀýÈç:
Ë÷Òý `idx_`(col1, col2, col3),ÄÇô²éѯ SELECT .... from ... WHERE col1=1 AND col2=2; ʹÓÃË÷Òý,¶ø²éѯ ... WHERE col2=2 AND col3=3; »ò ... WHERE col1=1 AND col3=3; Ôò²»Ê¹ÓÃË÷Òý.
* WHERE ÖеÄÌõ¼þÈç¹ûÓкãÁ¿ÀàÐ͵Ä(Èç `field` = 1),¾Í¾¡Á¿·ÅÔÚÇ°Ãæ,ÕâÑùÄܸü¿ìµÄÖ´ÐйýÂË.
* 2 ¸ö±íÁ¬½Óʱ,Á¬½Ó×ֶεÄÀàÐÍ×îºÃÒ»ÖÂ(°üÀ¨×ֶ㤶È),ÕâÑùµÄ»°Ë÷ÒýËٶȿì¶àÁË.
* ´ó²¿·ÖÇé¿öÏÂ,×Ö·ûÀàÐ͵


Ïà¹ØÎĵµ£º

MySql³£ÓÃÃüÁî

MySql³£ÓÃÃüÁî
 
¡¾MySqlÃüÁî´°¿ÚÆô¶¯£ºÇëÖ´ÐÐ\bin\mysql.exe¡¿
 
1:ʹÓÃSHOWÓï¾äÕÒ³öÔÚ·þÎñÆ÷Éϵ±Ç°´æÔÚʲôÊý¾Ý¿â£º
mysql> SHOW DATABASES;
2:´´½¨Ò»¸öÊý¾Ý¿âMYSQLDATA
mysql> CREATE DATABASE MYSQLDATA;
3:Ñ¡ÔñÄãËù´´½¨µÄÊý¾Ý¿â
mysql> USE MYSQLDATA; (°´»Ø³µ¼ü³öÏÖDatabase changed Ê±Ë ......

mysql Ë÷Òý


 
 
²é¿´Ä³¸ö±íµÄ½¨±íÓï¾ä £ºshow create table data_statdata;
drop index ts on data_statdata;
Ë÷ÒýÊǼÓËÙ²éѯµÄÖ÷ÒªÊֶΣ¬Ìرð¶ÔÓÚÉæ¼°¶à¸ö±íµÄ²éѯ¸üÊÇÈç´Ë¡£±¾½ÚÖУ¬½«½éÉÜË÷ÒýµÄ×÷Óá¢Ìص㣬ÒÔ¼°´´½¨ºÍɾ³ýË÷ÒýµÄÓï·¨¡£
13.4.1 ʹÓÃË÷ÒýÓÅ»¯²éѯ
Ë÷ÒýÊÇ¿ìËÙ¶¨Î»Êý¾ÝµÄ¼¼Êõ£¬Ê×ÏÈͨ¹ýÒ»¸öʾÀýÀ´Á˽ ......

mysqlµÄgrantÃüÁî

¹Ø¼ü×Ö: mysql grant
±¾ÎÄʵÀý£¬ÔËÐÐÓÚ MySQL 5.0 ¼°ÒÔÉÏ°æ±¾¡£
MySQL ¸³ÓèÓû§È¨ÏÞÃüÁîµÄ¼òµ¥¸ñʽ¿É¸ÅÀ¨Îª£º
grant ȨÏÞ on Êý¾Ý¿â¶ÔÏó to Óû§
Ò»¡¢grant ÆÕͨÊý¾ÝÓû§£¬²éѯ¡¢²åÈë¡¢¸üС¢É¾³ý Êý¾Ý¿âÖÐËùÓбíÊý¾ÝµÄȨÀû¡£
grant select on testdb.* to common_user@'%'
grant insert on testdb.* to common_user ......

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

1.ÓÅ»¯ÄãµÄMySQL²éѯ»º´æ
ÔÚMySQL·þÎñÆ÷ÉϽøÐвéѯ£¬¿ÉÒÔÆôÓøßËÙ²éѯ»º´æ¡£ÈÃÊý¾Ý¿âÒýÇæÔÚºǫ́ÇÄÇĵĴ¦ÀíÊÇÌá¸ßÐÔÄܵÄ×îÓÐЧ·½·¨Ö®Ò»¡£µ±Í¬Ò»¸ö²éѯ±»Ö´Ðжà´Îʱ£¬Èç¹û½á¹ûÊÇ´Ó»º´æÖÐÌáÈ¡£¬ÄÇÊÇÏ൱¿ìµÄ¡£
µ«Ö÷ÒªµÄÎÊÌâÊÇ£¬ËüÊÇÄÇôÈÝÒ×±»Òþ²ØÆðÀ´ÒÔÖÁÓÚÎÒÃÇ´ó¶àÊý³ÌÐòÔ±»áºöÂÔËü¡£ÔÚÓÐЩ´¦ÀíÈÎÎñÖУ¬ÎÒÃÇʵ¼ÊÉÏÊÇ¿ÉÒÔ×è ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ