mysql ÈÕÖ¾ÎļþµÄʹÓÃ
MYSQLÓв»Í¬ÀàÐ͵ÄÈÕÖ¾Îļþ(¸÷×Ô´æ´¢Á˲»Í¬ÀàÐ͵ÄÈÕÖ¾)£¬´ÓËüÃǵ±ÖпÉÒÔ²éѯµ½MYSQLÀﶼ×öÁËЩʲô£¬¶ÔÓÚMYSQLµÄ¹ÜÀí¹¤×÷£¬ÕâЩÈÕÖ¾ÎļþÊDz»¿ÉȱÉٵġ£
1.´íÎóÈÕÖ¾(The error log)£º¼Ç¼ÁËÊý¾Ý¿âÆô¶¯¡¢ÔËÐÐÒÔ¼°Í£Ö¹¹ý³ÌÖдíÎóÐÅÏ¢£»
2.ISAM²Ù×÷ÈÕÖ¾(The isam log)£º¼Ç¼ÁËËùÓжÔISAM±íµÄÐ޸ģ¬¸ÃÈÕÖ¾½ö½öÓÃÓÚµ÷ÊÔISAMģʽ£»
3.SQLÖ´ÐÐÈÕÖ¾(The query log)£º¼Ç¼ÁË¿Í»§¶ËµÄÁ¬½ÓÒÔ¼°ËùÖ´ÐеÄSQLÓï¾ä£»
4.¸üÐÂÈÕÖ¾(The update log)£º¼Ç¼Á˸ıäÊý¾ÝµÄÓï¾ä£¬ÒѾ²»½¨ÒéʹÓã¬Óɶþ½øÖÆÈÕÖ¾Ìæ´ú£»
5.¶þ½øÖÆÈÕÖ¾(The binary log)£º¼Ç¼ÁËËùÓжÔÊý¾Ý¿âÊý¾ÝµÄÐÞ¸ÄÓï¾ä£»
6.³¬Ê±ÈÕÖ¾(The slow log)£º¼Ç¼ËùÓÐÖ´ÐÐʱ¼ä³¬¹ý×î´óSQLÖ´ÐÐʱ¼ä(long_query_time)»òδʹÓÃË÷ÒýµÄÓï¾ä£»
Èç¹ûÄãÊÇÔÚÓÃmysqlµÄ¸´ÖÆ¡¢±¸·Ý¹¦ÄÜ£¬ÄÇô´Ó·þÎñÆ÷»¹ÌṩÁËÒ»ÖÖ½Ð×örelay logµÄÈÕÖ¾Îļþ¡£
ĬÈÏÇé¿öÏÂËùÓÐÈÕÖ¾Îļþ»á¼Ç¼ÔÚMYSQLµÄÊý¾ÝĿ¼Ï£¬Äã¿ÉÒÔͨ¹ýÇ¿ÖÆmysqlÈ¥¹Ø±Õ²¢ÖØдò¿ªÒ»¸öÎļþ½øÐÐÈÕÖ¾¼Ç¼£¬µ±È»ÏµÍ³»á×Ô¶¯¼Óºó׺
(Èç.00001, .00002)£¬·½Ê½ÓÐÔÚmysql»·¾³ÏÂÖ´ÐÐÓï¾ä mysql>flush logs;
»òÕßͨ¹ýmysqladmin¹ÜÀí³ÌÐòÖ´ÐÐ #mysqladmin flush-logs »ò #mysqladmin refresh
ÕâЩÈÕÖ¾µÄÆô¶¯·½Ê½¿ÉÒÔÔÚmysqld_safe·½Ê½Æô¶¯Êý¾Ý¿âµÄʱºò£¬ºóÃæ¸úÑ¡Ïî²ÎÊý£¬Ò²¿ÉÒÔÔÚÅäÖÃÎļþÀïÅäÖã¬ÍƼö²ÉÓõڶþÖÖ·½Ê½£¬ÅäÖ÷½·¨ºÜ¼òµ¥£¬ÎÒÖ»ÅäÖÃÁËÈýÖÖÈÕÖ¾£º
[mysqld]
log=/var/log/mysqld_common.log
log-error=/var/log/mysqld_err.log
log-bin=/var/log/mysqld_bin.bin
ÈÕÖ¾µÄ²é¿´ºÜ¼òµ¥£¬´ó²¿·Ö¶¼ÊÇÎı¾£¬Ö±½ÓÓÃvim¡¢less¡¢moreÖ®ÀàµÄ¹¤¾ß¿´¾Í¿ÉÒÔÁË£¬ÖµµÃ˵Ã÷µÄÊǶþ½øÖÆÎļþµÄ²é¿´£º
1). Ê×ÏÈÈ·¶¨ÊÇ·ñ¿ªÆôÁ˶þ½øÖÆÎļþ¼Ç¼¹¦ÄÜ
mysql>show variables like 'log_bin';
2). Èç¹ûÄãÏëÖªµÀÏÖÔڼǼ¶þ½øÖÆÊý¾ÝµÄÎļþ¾ßÌåÐÅÏ¢£¬Äã¿ÉÒÔͨ¹ýÏÂÁÐÓï¾ä¿´µ½ÏÖÔÚÕýÔڼǼÄĸöÎļþ£¬ÒÔ¼°¼Ç¼µÄµ±Ç°Î»Öãº
mysql>show master status;
3). ²é¿´¶þ½øÖÆÊý¾ÝÐèÒª½èÖú³ÌÐòmysqlbinlog£¬¿´¿´ËüÖ§³ÖÄÄЩѡÏ¸ù¾Ý×Ô¼ºÐèÒªÀ´Ê¹Óá£
mysql>mysqlbinlog /var/log/mysql/mysql-bin.000040;
²éѯij¸öʱ¼ä·¶Î§µÄ¿ÉÒÔÖ´ÐÐÏÂÁÐÓï¾ä£¬Èç¹û¼Ç¼ºÜ¶à¿ÉÒÔ½«½á¹û¶¨Ïòµ½Ò»¸öÎļþÀï×Ô¼ºÂýÂý¿´:-) £º
mysql>mysqlbinlog
--start-datetime='2008-01-01 00:00:00' --stop-datetime='2008-08-08
00:00:00' /var/log/mysql/mysql-bin.000040 > ./tmp.log
Ïà¹ØÎĵµ£º
http://blog.163.com/mysqldba@126/blog/static/1315356342009931103834396/
×î½ü¿´ÁË¿´mysqlµÄ״̬±äÁ¿£¬¸Ð¾õºÃ¶à¸úÒÔÇ°×Ô¼ºÏëÏóµÄ²»Ò»Ñù¡£ÎªÁËÒÔºóÄܼ°Ê±·¢ÏÖ×Ô¼ºµÄ´íÎó,¾ÍÏȼÇÏÂÀ´;
http://dev.mysql.com/doc/refman/5.1/en/server-status-variables.html
mysql> show status;
Com_xxx
Óï¾ä¼ÆÊý±äÁ¿±íʾÿ¸öxxx ......
ÓÃÔÚSELECTºÍWHERE×Ó¾äµÄº¯Êý
--------------------------------------------------------------
1 ·Ö×麯Êý
( ... ) À¨ºÅ¡£Ê¹ÓÃËüÃÇÀ´Ç¿ÖÆÔÚÒ»¸ö±í´ïʽµÄ¼ÆËã˳Ðò¡£
--------------------------------------------------------------
2 ³£ÓõÄËãÊõÔËËã
£¨+ - * /£©
Ò»°ãµÄË ......
1¡¢Ð½¨Êý¾ÝÔ´Îļþmysql-ds.xml,ÎļþÄÚÈÝÈçÏ£º
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/mydatabase?useUnico ......
create procedure getInfor2()
BEGIN
declare _abc varchar(200);
declare stopFlag int;
DECLARE cursor_name CURSOR
FOR
select zhuanyuan from server;
DECLARE CONTINUE HANDLER FOR NOT FOUND set stopFlag=1;
OPEN cursor_name;
REPEAT
FETCH cursor_name INTO _abc;
begin
if _abc='root'
the ......
×î½üÓõ½ÁËÒ»¿îÊý¾Ý¿âͼÐλ¯¹ÜÀí¹¤¾ßNavicat for MySQL £¬Ê¹ÓÃÖ®ºóÓÐÒ»Öָоõ£ºÔÀ´±à³Ì¿ÉÒԺܸßЧ£¡
ÒÔǰʹÓÃMySQLʱ£¬Ã¿´Î¶¼Ö»ÄÜÔÚÀàËÆDOSµÄ½çÃ濪·¢£¬Ê¹Óùٷ½ÌṩµÄ¹¤¾ßºÜÈÝÒ׾ͱ»¿¨µ½ÁË£¬¾õµÃ»¹ÊÇ×ÖÌõ½çÃæ±È½Ï¸ßЧ£¬µ«ÊdzõѧMySQL,ºÜ¶à¹¦Äܶ¼»¹Ã»ÓÐÍêÈ«Çå³þ£¬Ê¹Óð²È«ÐÔÉϵĿ¼ÂÇÒ²²»¹»³ÉÊì¡£ÕâʱºòÎÒ¿ ......