MYSQL¸´ÖÆ
ÅäÖø´ÖÆ
1.ÅäÖÃserver-idºÍlog-bin
2.Ö÷¿âÖÐÌí¼ÓÓÃÓÚ¸´ÖƵÄÓû§
GRANT REPLICATION SLAVE,reload,super ON *.*
TO 'repl'@'%.vm.dba.com' IDENTIFIED BY 'slavepass'
3.ÔÚ´Ó¿âÉÏÉèÖÃÓÃÓÚ¸´ÖƵÄÑ¡Ïî
server-id
master-host
master-user
master-password
--read-only ¸ÃÑ¡ÏîÈôӷþÎñÆ÷Ö»ÔÊÐíÀ´×Ô´Ó·þÎñÆ÷Ï̻߳ò¾ßÓÐSUPERȨÏÞµÄÓû§µÄ¸üС£¿ÉÒÔÈ·±£´Ó·þÎñÆ÷²»½ÓÊÜÀ´×Ô¿Í»§µÄ¸üС£
--replicate-do-db=db_name ¸æËß´Ó·þÎñÆ÷ÏÞÖÆĬÈÏÊý¾Ý¿â(ÓÉUSEËùÑ¡Ôñ)Ϊdb_nameµÄÓï¾äµÄ¸´ÖÆ¡£
--replicate-wild-do-table=db_name.% ¿çÊý¾Ý¿â½øÐиüÐÂ
--replicate-do-table=db_name.tbl_name ¸æËß´Ó·þÎñÆ÷Ïß³ÌÏÞÖƶÔÖ¸¶¨±íµÄ¸´ÖÆ¡£
--replicate-ignore-db=db_name ¸æËß´Ó·þÎñÆ÷²»Òª¸´ÖÆĬÈÏÊý¾Ý¿â(ÓÉUSEËùÑ¡Ôñ)Ϊdb_nameµÄÓï¾ä¡£
--replicate-ignore-table=db_name.tbl_name ¸æËß´Ó·þÎñÆ÷Ï̲߳»Òª¸´ÖƸüÐÂÖ¸¶¨±íµÄÈκÎÓï¾ä(¼´Ê¹¸ÃÓï¾ä¿ÉÄܸüÐÂÆäËüµÄ±í)¡£
--replicate-wild-do-table=db_name.tbl_name ¸æËß´Ó·þÎñÆ÷Ïß³ÌÏÞÖƸ´ÖƸüеıíÆ¥ÅäÖ¸¶¨µÄÊý¾Ý¿âºÍ±íÃûģʽµÄÓï¾ä¡£
--replicate-wild-ignore-table=db_name.tbl_name ¸æËß´Ó·þÎñÆ÷Ï̲߳»Òª¸´ÖƱíÆ¥Åä¸ø³öµÄͨÅä·ûģʽµÄÓï¾ä¡£
--replicate-rewrite-db=from_name->to_name ¸æËß´Ó·þÎñÆ÷Èç¹ûĬÈÏÊý¾Ý¿â(ÓÉUSEËùÑ¡Ôñ)ΪÖ÷·þÎñÆ÷ÉϵÄfrom_name£¬Ôò·ÒëΪto_name¡£
--skip-slave-start ¸æËß´Ó·þÎñÆ÷µ±·þÎñÆ÷Æô¶¯Ê±²»Æô¶¯´Ó·þÎñÆ÷Ï̡߳£Ê¹ÓÃSTART SLAVEÓï¾äÔÚÒÔºóÆô¶¯Ï̡߳£
--slave-skip-errors=[err_code1,err_code2,... | all] ¸ÃÑ¡Ïî¸æËß´Ó·þÎñÆ÷SQLÏ̵߳±Óï¾ä·µ»ØÈκÎÑ¡ÏîÖµÖÐËùÁеĴíÎóʱ¼ÌÐø¸´ÖÆ¡£
4.´ÓÖ÷¿âͬ²½Êý¾Ýµ½´Ó¿â
4.1 load data from master;
4.2 ±¸·Ý»¹Ô·½Ê½
4.2.1 Æô¶¯´Ó·þÎñÆ÷¡£Èç¹ûÇ°ÃæÒѾ¸´ÖÆÁË£¬ÓÃ--skip-slave-startÑ¡ÏîÆô¶¯´Ó·þÎñÆ÷£¬ÒÔ±ãËü²»Á¢¼´³¢ÊÔÁ¬½ÓÖ÷·þÎñÆ÷¡£
4.2.2 Èç¹ûʹÓÃmysqldump±¸·ÝÖ÷·þÎñÆ÷µÄÊý¾Ý£¬½«×ª´¢Îļþ×°Ôص½´Ó·þÎñÆ÷¡£
cmd> mysql -u root -p < dump_file.sql
4.2.3 ÉèÖÃÁ¬½Ó²ÎÊý
mysql> CHANGE MASTER TO
-> MASTER_HOST='master_ho
Ïà¹ØÎĵµ£º
[תÌûÍøÖ·]http://java-2007.javaeye.com/blog/622269
Íü¼ÇMySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ) ROOTÃÜÂëÊÇÔÚMySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)ʹÓÃÖкܳ£¼ûµÄÎÊÌ⣬¿ÉÊÇÓкܶàÅóÓѲ¢²»»áÖØÖÃROOTÃÜÂ룬Äǽпడ£¬ÎÒÓÐÉîÓид¥£¬ÌØд´ËÎÄÕÂÓë´ó¼Ò½»Á÷£º
1¡¢±à¼MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)ÅäÖÃÎļþ£º
windows»·¾³ÖУº%MySQL(ºÍPHP´îÅäÖ ......
ÎÒд¹ýµÄ½Ì³Ì²»¶à£¬¶øÇҴ󲿷ֶ¼ÊÇÀ´Ô´ÓÚ±ðÈ˵Ľ̳̣¬²»¹ý£¬ÕâÀïËù½éÉܵģ¬¶¼ÊÇÈÚÈëÎÒËù×ܽáµÄ¾Ñ飮££ÒýÑÔ
¡¡¡¡
¡¡¡¡PHPµÄÖ´ÐÐЧÂÊÊÇÓÐÄ¿¹²¶ÃµÄ£¬ÕâÒ²ÊÇÎÒϲ»¶ËüµÄÔÒòÖ®Ò»£¬ºÍËü³ÆΪ¾øÃî´îµµµÄMysqlÒÔ¼°ApacheÏëÈںϣ¬²»Äܲ»¾ªÌ¾ÆäЧÂÊÁË¡£PHP¸üÐÂÒ²ºÜ¿ì£¬ÕâÀïÁоÙÁËÄ¿Ç°×îа汾PHP4.3.2RC4£¨¼¸ºõûÓÐBUGÁË£¬¹À¼ÆÐ´Í ......
ERROR 1005 (HY000): Can't create table ' ****.frm' (errno: 150)
ÎÒÊÇ´ÓÒÔϼ¸¸ö·½Ãæ½â¾öÁË´ËÎÊÌ⣺
1¡¢È·±£²ÎÕյıíºÍ×Ö¶ÎÊÇ´æÔڵģ»
2¡¢×é³ÉÍâ¼üµÄ×Ö¶ÎÒªÇó±»Ë÷Òý(Ö÷ÒªÊÇÍâ¼üÄǸö×Ö¶ÎÒªÇóÔÚÆäËû±íÖÐÊÇÖ÷¼ü)£»
3¡¢Íâ¼ü¹ØÁªµÄÁ½±í»ò¶à±íÒªÇó¶¼ÊÇINNODBÀàÐÍµÄ±í£»
4¡¢×Ö¶ÎÀàÐÍ£¨ËµÃ÷£©ÒªÒ»Ñù`itemId` varchar( ......
(1)
´æ´¢¹ý³ÌÊÇÊý¾Ý¿â·þÎñÆ÷¶ËµÄÒ»¶Î³ÌÐò.
mysqlµÄ´æ´¢¹ý³Ì,Ö»Óа汾ÊÇmysql5.0»òÒÔÉϵIJÅÓдËÌØÐÔ.
(2)
ʲôʱºòÐèÒªÓô洢¹ý³Ì
´æ´¢¹ý³Ìͨ³£ÊÇһЩ¾³£ÒªÖ´ÐеÄÈÎÎñ£¬ÕâЩÈÎÎñÍùÍùÊÇÕë¶Ô´óÁ¿µÄ¼Ç¼¶ø½øÐеġ£ÔÚ·þÎñÆ÷ÉÏÖ´Ðд洢¹ý³Ì£¬¿ÉÒÔ
¸ÄÉÆÓ¦ÓóÌÐòµÄÐÔÄÜ¡£ÕâÊÇÒòΪ£º
2.1.
·þÎñÆ÷ÍùÍù¾ßÓÐÇ¿´óµÄ¼ÆËãÄÜÁ¦ºÍËÙ ......
µ¼³ö
select field1,field2,field3 from tablename into outfile '/home/output1.csv' fields terminated by ','optionally enclosed by ''lines terminated by '\n';
µ¼Èë
load data local infile '/home/output1.csv' into table tablename fields terminated by ','lines terminated by '\n'(field1,f ......