MySQLÐÔÄÜÓÅ»¯
ÔÚApache, PHP, MySQLµÄÌåϵ¼Ü¹¹ÖУ¬MySQL¶ÔÓÚÐÔÄܵÄÓ°Ïì×î´ó£¬Ò²ÊǹؼüµÄºËÐIJ¿·Ö¡£¶ÔÓÚDiscuz!ÂÛ̳³ÌÐòÒ²ÊÇÈç´Ë£¬MySQLµÄÉèÖÃÊÇ·ñºÏÀíÓÅ»¯£¬Ö±½ÓÓ°Ïìµ½ÂÛ̳µÄËٶȺͳÐÔØÁ¿£¡Í¬Ê±£¬MySQLÒ²ÊÇÓÅ»¯ÄѶÈ×î´óµÄÒ»¸ö²¿·Ö£¬²»µ«ÐèÒªÀí½âһЩMySQLרҵ֪ʶ£¬Í¬Ê±»¹ÐèÒª³¤Ê±¼äµÄ¹Û²ìͳ¼Æ²¢ÇÒ¸ù¾Ý¾Ñé½øÐÐÅжϣ¬È»ºóÉèÖúÏÀíµÄ²ÎÊý¡£
ÏÂÃæÎÒÃÇÁ˽âÒ»ÏÂMySQLÓÅ»¯µÄһЩ»ù´¡£¬MySQLµÄÓÅ»¯ÎÒ·ÖΪÁ½¸ö²¿·Ö£¬Ò»ÊÇ·þÎñÆ÷ÎïÀíÓ²¼þµÄÓÅ»¯£»¶þÊÇMySQL×ÔÉí(my.cnf)µÄÓÅ»¯¡£
(1) ·þÎñÆ÷Ó²¼þ¶ÔMySQLÐÔÄܵÄÓ°Ïì
a) ´ÅÅÌÑ°µÀÄÜÁ¦£¨´ÅÅÌI/O£©,ÒÔÄ¿Ç°¸ßתËÙSCSIÓ²ÅÌ(7200ת/Ãë)ΪÀý£¬ÕâÖÖÓ²ÅÌÀíÂÛÉÏÿÃëÑ°µÀ7200´Î£¬ÕâÊÇÎïÀíÌØÐÔ¾ö¶¨µÄ£¬Ã»Óа취¸Ä±ä¡£ MySQLÿÃëÖÓ¶¼ÔÚ½øÐдóÁ¿¡¢¸´ÔӵIJéѯ²Ù×÷£¬¶Ô´ÅÅ̵ĶÁдÁ¿¿ÉÏë¶øÖª¡£ËùÒÔ£¬Í¨³£ÈÏΪ´ÅÅÌI/OÊÇÖÆÔ¼MySQLÐÔÄܵÄ×î´óÒòËØÖ®Ò»£¬¶ÔÓÚÈÕ¾ù·ÃÎÊÁ¿ÔÚ100ÍòPVÒÔÉϵÄDiscuz!ÂÛ̳£¬ÓÉÓÚ´ÅÅÌI/OµÄÖÆÔ¼£¬MySQLµÄÐÔÄÜ»á·Ç³£µÍÏ£¡½â¾öÕâÒ»ÖÆÔ¼ÒòËØ¿ÉÒÔ¿¼ÂÇÒÔϼ¸ÖÖ½â¾ö·½°¸£º
ʹÓÃRAID-0+1´ÅÅÌÕóÁУ¬×¢Òâ²»Òª³¢ÊÔʹÓÃRAID-5£¬MySQLÔÚRAID-5´ÅÅÌÕóÁÐÉϵÄЧÂʲ»»áÏñÄãÆÚ´ýµÄÄÇÑù¿ì£» Å×Æú´«Í³µÄÓ²ÅÌ£¬Ê¹ÓÃËٶȸü¿ìµÄÉÁ´æʽ´æ´¢É豸¡£¾¹ýDiscuz!¹«Ë¾¼¼Êõ¹¤³ÌµÄ²âÊÔ£¬Ê¹ÓÃÉÁ´æʽ´æ´¢É豸¿É±È´«Í³Ó²ÅÌËٶȸ߳ö6£10±¶×óÓÒ¡£
b) CPU ¶ÔÓÚMySQLÓ¦Óã¬ÍƼöʹÓÃS.M.P.¼Ü¹¹µÄ¶à·¶Ô³ÆCPU£¬ÀýÈ磺¿ÉÒÔʹÓÃÁ½¿ÅIntel Xeon 3.6GHzµÄCPU¡£
c) ÎïÀíÄÚ´æ¶ÔÓÚһ̨ʹÓÃMySQLµÄDatabase ServerÀ´Ëµ£¬·þÎñÆ÷Äڴ潨Ò鲻ҪСÓÚ2GB£¬ÍƼöʹÓÃ4GBÒÔÉϵÄÎïÀíÄÚ´æ¡£
(2) MySQL×ÔÉíÒòËص±½â¾öÁËÉÏÊö·þÎñÆ÷Ó²¼þÖÆÔ¼ÒòËغó£¬ÈÃÎÒÃÇ¿´¿´MySQL×ÔÉíµÄÓÅ»¯ÊÇÈçºÎ²Ù×÷µÄ¡£¶ÔMySQL×ÔÉíµÄÓÅ»¯Ö÷ÒªÊǶÔÆäÅäÖÃÎļþmy.cnfÖеĸ÷Ïî²ÎÊý½øÐÐÓÅ»¯µ÷Õû¡£ÏÂÃæÎÒÃǽéÉÜһЩ¶ÔÐÔÄÜÓ°Ïì½Ï´óµÄ²ÎÊý¡£
ÓÉÓÚmy.cnfÎļþµÄÓÅ»¯ÉèÖÃÊÇÓë·þÎñÆ÷Ó²¼þÅäÖÃϢϢÏà¹ØµÄ£¬Òò¶øÎÒÃÇÖ¸¶¨Ò»¸ö¼ÙÏëµÄ·þÎñÆ÷Ó²¼þ»·¾³£º
CPU: 2¿ÅIntel Xeon 2.4GHz
ÄÚ´æ: 4GB DDR
Ó²ÅÌ: SCSI 73GB
ÏÂÃ棬ÎÒÃǸù¾ÝÒÔÉÏÓ²¼þÅäÖýáºÏÒ»·ÝÒѾÓÅ»¯ºÃµÄmy.cnf½øÐÐ˵Ã÷£º
# vi /etc/my.cnf
ÒÔÏÂÖ»Áгömy.cnfÎļþÖÐ[mysqld]¶ÎÂäÖеÄÄÚÈÝ£¬ÆäËû¶ÎÂäÄÚÈݶÔMySQLÔËÐÐÐÔÄÜÓ°ÏìÉõ΢£¬Òò¶ø¹ÃÇÒºöÂÔ¡£
[mysqld]
port = 3306
serverid = 1
socket = /tmp/mysql.sock
skip-locking
# ±ÜÃâMySQLµÄÍⲿËø¶¨£¬¼õÉÙ³ö´í¼¸ÂÊÔöÇ¿Îȶ¨ÐÔ¡£
skip-name-resolve
½ûÖ¹MySQL¶ÔÍⲿÁ¬½Ó½øÐÐDNS½âÎö£¬Ê¹
Ïà¹ØÎĵµ£º
ÍíÉÏÓÐÅóÓÑÎÊÆ𣬼òµ¥µÄдÁËÒ»¸ö¡£
DELIMITER $$
CREATE
FUNCTION `t_girl`
.
`func_rand_string`
(
f_num tinyint
unsigned
,
f_type tinyint
unsigned
)
RETURNS varchar
(
32)
BEGIN
......
ÍêÈ«°²×°°ü
http://mysql.isu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.38-win32.msi
°üº¬ÁË°²×°MySQLËùÐèÒªµÄÈ«²¿ÎļþÓëÅäÖÃÏòµ¼ÒÔ¼°¿ÉÑ¡×é¼þ£¬Èç»ù×¼Ì×¼þºÍǶÈëʽ·þÎñÆ÷
»ù±¾°²×°°ü
http://mysql.isu.edu.tw/Downloads/MySQL-5.1/mysql-essential-5.1.38-win32.msi
Ö»°üº¬ÁË°²×°MySQLËùÐèÒªµÄ»ù±¾ÎļþÓëÅäÖÃÏòµ¼£¬µ«ÊÇ ......
MYSQLÍü¼ÇROOTÃÜÂëºó£¿
ÐÞ¸ÄMySQLµÄµÇ¼ÉèÖãº
1.È¡ÏûȨÏÞ¹ÜÀí
±à¼ /mysql5.1/my.ini
ÔÚ[mysqld]µÄ¶ÎÖмÓÉÏÒ»¾ä£ºskip-grant-tables
ÀýÈ磺
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
Ä¿µÄÊÇΪÁË£º
Ìø¹ýMySQLµÄ·ÃÎ ......
Ò».Óï·¨
explain < table_name >
ÀýÈç: explain select * from t3 where id=3952602;
¶þ.explainÊä³ö½âÊÍ
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key ......