¹ØÓÚMySQL¶þ½øÖÆÈÕÖ¾BinlogµÄÈÏʶ
MySQLµÄ¶þ½øÖÆÈÕÖ¾¿ÉÒÔ˵»òÊÇMySQL×îÖØÒªµÄÈÕÖ¾ÁË,Ëü¼Ç¼ÁËËùÓеÄDDLºÍDML(³ýÁËÊý¾Ý²éѯÓï¾ä)Óï¾ä,ÒÔʼþÐÎʽ¼Ç¼,»¹°üº¬Óï¾äËùÖ´ÐеÄÏûºÄµÄʱ¼ä,MySQLµÄ¶þ½øÖÆÈÕÖ¾ÊÇʧÎó°²È«Ð͵Ä.
ÔÚ5.1µÄ°æ±¾Äã¶þ½øÖÆÈÕÖ¾»¹Ìæ´úÁËÔ±¾µÄ¸üÐÂÈÕÖ¾.Ò»°ãÀ´Ëµ¿ªÆô¶þ½øÖÆÈÕÖ¾´ó¸Å»áÓÐ1%µÄÐÔÄÜËðºÄ(²Î¼ûMySQL¹Ù·½ÖÐÎÄÊÖ²á5.1.24°æ).¶þ½øÖÆÓÐÁ½¸ö×îÖØÒªµÄʹÓó¡¾°:
ÆäÒ»ÊÇ:MySQL ReplicationÔÚMaster¶Ë¿ªÆôbinlog,Mster°ÑËüµÄ¶þ½øÖÆÈÕÖ¾´«µÝ¸øslavesÀ´´ïµ½master-slaveÊý¾ÝÒ»Ö±µÄÄ¿µÄ.
Æä¶þ:×ÔÈ»¾ÍÊÇÊý¾Ý»Ö¸´ÁË,ͨ¹ýʹÓÃmysqlbinlog¹¤¾ßÀ´»Ö¸´Êý¾Ý.
binlog²»Ö§³Öselect,showÒ»ÀàÓï¾ä,Èç¹ûÒª¼Ç¼ÕâЩÓï¾ä¿ÉÒÔͨ¹ý´ò¿ªMySQLµÄgeneral logÀ´´óµ½Ä¿µÄ.
¿ÉÒÔÀûÓÃmysqlbinlog¹¤¾ßÀ´²é¿´¶þ½øÖÆÈÕÖ¾,´ò¿ªÒ»¸öÕýÔÚʹÓõÄbinlog
$mysqlbinlog var/mysql-bin.000022
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#091222 18:09:33 server id 2 end_log_pos 106 Start: binlog v 4, server v 5.1.41-debug-log created 091222 18:09:33 at startup
# Warning: this binlog was not closed properly. Most probably mysqld crashed writing it.
ROLLBACK/*!*/;
# at 106
#091222 23:20:35 server id 2 end_log_pos 174 Query thread_id=4 exec_time=1 error_code=0
SET TIMESTAMP=1261495235/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
BEGIN
/*!*/;
# at 174
#091222 23:20:35 server id 2 end_log_pos 269 Query thread_id=4 exec_time=0 error_code=0
use test/*!*/;
SET TIMESTAMP=1261495235/*!*/;
insert bench values(20,'xiaojj')
/*!*/;
# at 269
#091222 23:20:35 server id 2 end_log_pos 296 Xid = 22
COMMIT/*!*/;
DELIMITER ;
# End of log file
Ïà¹ØÎĵµ£º
°´ÕÕÊֲᰲװMySQL Proxy֮ǰÏÈÒª°²×°ÒÔÏÂÈí¼þ libevent 1.x or higher (1.3b or later is preferred) lua 5.1.x or higher glib2 2.6.0 or higher pkg-config libtool 1.5 or higher MySQL 5.0.x or higher developer files rpm²é¿´libevent $rpm -q libevent
libevent-1.1a-3.2. ......
±à¼/etc/mysql/my.cnfÎļþ£¬Ï൱ÓÚwindowsÖеÄmy.ini£º
ÕÒµ½[client]
Ìí¼Ó£º
default-character-set = utf8 // ĬÈÏ×Ö·û¼¯Îªutf8
ÕÒµ½[mysqld]
Ìí¼Ó:
default-character-set = utf8 //ĬÈÏ×Ö·û¼¯Îªutf8
init_connect = 'SET NAMES utf8' //É趨Á¬½ÓmysqlÊý¾Ý¿âʱʹÓÃutf8±àÂ룬ÒÔÈÃmysqlÊý¾Ý¿âΪutf8ÔËÐÐ
Ð޸ĺú ......
1. mysqldump -u username -h somehost -p --compatible=mysql40 db_name > temp.sql
2. ÓÃphpmyadminÇå¿ÕÊý¾Ý¿â²¢ÉèÖÃÊý¾Ý¿âÕûÀíΪutf8_general_ci
3. mysql -u username -h somehost -p --default-character-set=utf8 db_name < temp.sql ......
1¡¢ÏÂÔØMySQLÃâ°²×°°æ/¶þ½øÖÆ°æÈí¼þ£¨²»ÓñàÒ룩
Îļþ¸ñʽ£ºMYSQL-VERSION-OS.tar.gz
2¡¢´´½¨MySQL×飬½¨Á¢MySQLÓû§²¢¼ÓÈëµ½mysql×éÖÐ
£¨²»Í¬°æ±¾µÄUnixÖУ¬groupaddºÍuseraddµÄÓï·¨¿ÉÄÜ»áÉÔÓв»Í¬¡££©
#groupadd mysql
#useradd -g mysql mysql
3¡¢½øÈëĿ¼/usr/local£¬½âѹËõÃâ°²×°°æ£¬²¢ÔÚ ......
mysql> flush privileges;ʲôÒâ˼£¿
mysql> update mysql.user set password=PASSWORD('ÐÂÃÜÂë') where User='root';
mysql> flush privileges;
mysql> quit
´ð:
mysql ÐÂÉèÖÃÓû§»ò¸ü¸ÄÃÜÂëºóÐèÓÃflush privilegesË¢ÐÂMySQLµÄϵͳȨÏÞÏà¹Ø±í£¬·ñÔò»á³öÏ־ܾø·ÃÎÊ£¬»¹ÓÐÒ»ÖÖ·½· ......