(ת)mysqlÄÚ´æµ÷ÓÅ
key_buffer_size - Õâ¶ÔMyISAM±íÀ´Ëµ·Ç³£ÖØÒª¡£Èç¹ûÖ»ÊÇʹÓÃMyISAM±í£¬¿ÉÒÔ°ÑËüÉèÖÃΪ¿ÉÓÃÄÚ´æµÄ 30-40%¡£ºÏÀíµÄֵȡ¾öÓÚË÷Òý´óС¡¢Êý¾ÝÁ¿ÒÔ¼°¸ºÔØ¡£
¼Çס£¬MyISAM±í»áʹÓòÙ×÷ϵͳµÄ»º´æÀ´»º´æÊý¾Ý£¬Òò´ËÐèÒªÁô³ö²¿·ÖÄÚ´æ¸øËüÃÇ£¬ºÜ¶àÇé¿öÏÂÊý¾Ý±ÈË÷Òý´ó¶àÁË¡£¾¡¹ÜÈç´Ë£¬ÐèÒª×ÜÊǼì²éÊÇ·ñËùÓÐµÄ key_buffer ¶¼±»ÀûÓÃÁË¡£
.MYI ÎļþÖ»ÓÐ 1GB£¬¶ø key_buffer È´ÉèÖÃΪ 4GB µÄÇé¿öÊǷdz£Éٵġ£Õâô×öÌ«ÀË·ÑÁË¡£Èç¹ûÄãºÜÉÙʹÓÃMyISAM±í£¬ÄÇôҲ±£ÁôµÍÓÚ 16-32MB µÄ key_buffer_size ÒÔÊÊÓ¦¸øÓè´ÅÅ̵ÄÁÙʱ±íË÷ÒýËùÐè¡£
innodb_buffer_pool_size - Õâ¶ÔInnodb±íÀ´Ëµ·Ç³£ÖØÒª¡£InnodbÏà±ÈMyISAM±í¶Ô»º³å¸üΪÃô¸Ð¡£MyISAM¿ÉÒÔÔÚĬÈ쵀 key_buffer_size ÉèÖÃÏÂÔËÐеĿÉÒÔ£¬È»¶øInnodbÔÚĬÈ쵀 innodb_buffer_pool_size ÉèÖÃÏÂÈ´¸úÎÏÅ£ËƵġ£ÓÉÓÚInnodb°ÑÊý¾ÝºÍË÷Òý¶¼»º´æÆðÀ´£¬ÎÞÐèÁô¸ø²Ù×÷ϵͳ̫¶àµÄÄڴ棬Òò´ËÈç¹ûÖ»ÐèÒªÓÃInnodbµÄ»°Ôò¿ÉÒÔÉèÖÃËü¸ß´ï 70-80% µÄ¿ÉÓÃÄÚ´æ¡£Èç¹ûÄãµÄÊý¾ÝÁ¿²»´ó£¬²¢ÇÒ²»»á±©Ôö£¬ÄÇôÎÞÐè°Ñ innodb_buffer_pool_size ÉèÖõÄÌ«´óÁË¡£
innodb_additional_pool_size - Õâ¸öÑ¡Ïî¶ÔÐÔÄÜÓ°Ïì²¢²»Ì«¶à£¬ÖÁÉÙÔÚÓв¶à×ã¹»ÄÚ´æ¿É·ÖÅäµÄ²Ù×÷ϵͳÉÏÊÇÕâÑù¡£²»¹ýÈç¹ûÄãÈÔÈ»ÏëÉèÖÃΪ 20MB(»òÕ߸ü´ó)£¬Òò´Ë¾ÍÐèÒª¿´Ò»ÏÂInnodbÆäËûÐèÒª·ÖÅäµÄÄÚ´æÓжàÉÙ¡£
innodb_log_file_size ÔÚ¸ßдÈ븺ÔØÓÈÆäÊÇ´óÊý¾Ý¼¯µÄÇé¿öϺÜÖØÒª¡£Õâ¸öÖµÔ½´óÔòÐÔÄÜÏà¶ÔÔ½¸ß£¬µ«ÊÇҪעÒâµ½¿ÉÄÜ»áÔö¼Ó»Ö¸´Ê±¼ä¡£ÎÒ¾³£ÉèÖÃΪ 64-512MB£¬¸ú¾Ý·þÎñÆ÷´óС¶øÒì¡£innodb_log_buffer_size ĬÈϵÄÉèÖÃÔÚÖеÈÇ¿¶ÈдÈ븺ÔØÒÔ¼°½Ï¶ÌÊÂÎñµÄÇé¿öÏ£¬·þÎñÆ÷ÐÔÄÜ»¹¿ÉÒÔ¡£Èç¹û´æÔÚ¸üвÙ×÷·åÖµ»òÕ߸ºÔؽϴ󣬾ÍÓ¦¸Ã¿¼ÂǼӴóËüµÄÖµÁË¡£Èç¹ûËüµÄÖµÉèÖÃÌ«¸ßÁË£¬¿ÉÄÜ»áÀË·ÑÄÚ´æ¡£ËüÿÃ붼»áË¢ÐÂÒ»´Î£¬Òò´ËÎÞÐèÉèÖó¬¹ý1ÃëËùÐèµÄÄÚ´æ¿Õ¼ä¡£Í¨³£ 8-16MB ¾Í×ã¹»ÁË¡£Ô½Ð¡µÄϵͳËüµÄֵԽС¡£
innodb_flush_logs_at_trx_commit ÊÇ·ñΪInnodb±ÈMyISAMÂý1000±¶¶øÍ·´ó£¿¿´À´Ò²ÐíÄãÍüÁËÐÞ¸ÄÕâ¸ö²ÎÊýÁË¡£Ä¬ÈÏÖµÊÇ 1£¬ÕâÒâζ×Åÿ´ÎÌá½»µÄ¸üÐÂÊÂÎñ£¨»òÕßÿ¸öÊÂÎñÖ®ÍâµÄÓï¾ä£©¶¼»áˢе½´ÅÅÌÖУ¬¶øÕâÏ൱ºÄ·Ñ×ÊÔ´£¬ÓÈÆäÊÇûÓеç³Ø±¸Óûº´æʱ¡£ºÜ¶àÓ¦ÓóÌÐò£¬ÓÈÆäÊÇ´Ó MyISAMת±ä¹ýÀ´µÄÄÇЩ£¬°ÑËüµÄÖµÉèÖÃΪ 2 ¾Í¿ÉÒÔÁË£¬Ò²¾ÍÊDz»°ÑÈÕ־ˢе½´ÅÅÌÉÏ£¬¶øֻˢе½²Ù×÷ϵͳµÄ»º´æÉÏ¡£ÈÕÖ¾ÈÔÈ»»áÿÃëˢе½´ÅÅÌÖÐÈ¥£¬Òò´Ëͨ³£²»»á¶ªÊ§Ã¿Ãë1-2´Î¸üеÄÏûºÄ¡£Èç¹ûÉèÖÃΪ 0 ¾Í¿ìºÜ¶àÁË£¬²»¹ýÒ²Ïà¶Ô²
Ïà¹ØÎĵµ£º
Ò»,½ñÌì¸ø´ó¼Ò½²Ò»ÏÂ,×öÁôÑÔµÄÒ»ÖÖ×·¼ÓµÄ·½Ê½Ö÷ÒªÈç¹ûµ±Ç°ÓÐÁôÑÔ,¾Í¸üе±Ç°µÄÁôÑÔÒÔ×·¼ÓµÄ·½Ê½,Èç¹ûûÄÜÁôÑԾͽ«ÈëÒ»ÌõеÄ
mysql:insert into `table` (field) values ('$value') on duplicate key update `field`=concat('value',ifnull(`field`,''));
¾ßÌå±¾ÌõSQLµÄÓ÷¨,Çë²é¿´ÊÖ²á
¶þ,½²Ò»ÏÂͳ¼ÆµÄÓ÷¨,Ö÷Òª½éÉÜÈçº ......
USE dxdb;
DELIMITER //
#»ñÈ¡Á÷Ë®ºÅ
DROP PROCEDURE IF EXISTS get_sid;
CREATE PROCEDURE get_sid(para_domain VARCHAR(20), out para_sid BIGINT UNSIGNED)
BEGIN
START TRANSACTION;
UPDATE t_sid SET sID=sID+1 WHERE cDomain=para_domain;
SELECT sID INTO para_sid from t_sid WHERE cDomain=para_domain;
......
Õ⼸ÌìѧϰÁË´¥·¢Æ÷µÄÓ÷¨£¬¾õµÃ´¥·¢Æ÷ºÜºÃÓð¡¡£
´¥·¢Æ÷µÄ»ù±¾Óï·¨£º
CREATE TRIGGER <´¥·¢Æ÷Ãû><--
{BEFORE | AFTER}
{ INSERT | UPDATE | DELETE }
ON <±íÃû³Æ>
FOR EACH ROW
<´¥·¢Æ÷SQLÓï¾ä>
¹æÔò£º
1.´¥·¢Æ÷±ØÐëÓÐÃû×Ö£¬×î¶à64¸ö×Ö·û£¬¿ÉÄܺóÃæ»á¸½Óзָô·û.ËüºÍMySQLÖÐÆäËû¶ÔÏóµÄÃüÃû· ......
mysql 5.0´æ´¢¹ý³Ìѧϰ×ܽá
Ò».´´½¨´æ´¢¹ý³Ì
1.»ù±¾Óï·¨£º
create procedure sp_name()
begin
………
end
2.²ÎÊý´«µÝ
¶þ.µ÷Óô洢¹ý³Ì
1.»ù±¾Óï·¨£ºcall sp_name()
×¢Ò⣺´æ´¢¹ý³ÌÃû³ÆºóÃæ±ØÐë¼ÓÀ¨ºÅ£¬ÄÄŸô洢¹ý³ÌûÓвÎÊý´«µÝ
Èý.ɾ³ý´æ´¢¹ý³Ì
1.»ù±¾Óï·¨£º
drop procedure sp_na ......
mysql ±àÒë°²×°Óë±àÒë²ÎÊý
Ìí¼Ómysql×éºÍmysqlÓû§
[root@centos mysql]# groupadd mysql
[root@centos mysql]# useradd -g mysql mysql
±àÒëÓë°²×°
tar -zxvf mysql-5.1.35.tar.gz
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/data/mysql/data \ m ......