ÉèÖÃMySQLÊý¾Ýͬ²½£¨µ¥Ïò&Ë«Ïò£©
ÉèÖÃMySQLÊý¾Ýͬ²½£¨µ¥Ïò&Ë«Ïò£©
ÓÉÓÚ¹«Ë¾µÄÒµÎñÐèÇó£¬ÐèÒªÍøͨºÍµçÐŵÄÊý¾Ýͬ²½£¬¾Í×öÁ˸öMySQLµÄË«Ïòͬ²½£¬¼ÇϹý³Ì£¬ÒÔºóÓõõ½ÔÙ·³öÀ´£¬Ò²Ìù³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢×¼±¸·þÎñÆ÷
ÓÉÓÚMySQL²»Í¬°æ±¾Ö®¼äµÄ(¶þ½øÖÆÈÕÖ¾)binlog¸ñʽ¿ÉÄܻ᲻һÑù£¬Òò´Ë×îºÃµÄ´îÅä×éºÏÊÇMasterµÄMySQL°æ±¾ºÍSlaveµÄ°æ±¾Ïàͬ»òÕ߸üµÍ£¬MasterµÄ°æ±¾¿Ï¶¨²»ÄܸßÓÚSlave°æ±¾¡£
±¾ÎÄÖУ¬ÎÒÃǼÙÉèÖ÷·þÎñÆ÷(ÒÔϼò³ÆMaster)ºÍ´Ó·þÎñÆ÷(ÒÔϼò³ÆSlave)µÄ°æ±¾¶¼ÊÇ5.0.27£¬²Ù×÷ϵͳÊÇRedHat Linux 9¡£
¼ÙÉèͬ²½MasterµÄÖ÷»úÃûΪ£ºA(IP:192.168.0.1)£¬SlaveÖ÷»úÃûΪ£ºB(IP:192.168.0.2)£¬2¸öMySQLµÄbasedirĿ¼¶¼ÊÇ/usr/local/mysql£¬datadir¶¼ÊÇ£º/var/lib/mysql¡£
¶þ¡¢ÉèÖÃͬ²½·þÎñÆ÷
1¡¢ÉèÖÃͬ²½Master
ÐÞ¸Ä my.cnf Îļþ£¬ÔÚ
# Replication Master Server (default)
# binary logging is required for replication
Ìí¼ÓÈçÏÂÄÚÈÝ£º
log-bin=/var/log/mysql/updatelog
server-id = 1
binlog-do-db=test
binlog-ignore-db=mysql
ÖØÆôMySQL,´´½¨Ò»¸öMySQLÕʺÅΪͬ²½×¨ÓÃ
GRANT REPLICATION SLAVE,RELOAD,SUPER, ON *.* TO back@192.168.0.2 IDENTIFIED BY 'back' ;
FLUSH PRIVILEGES ;
2¡¢ÉèÖÃͬ²½Slave
ÐÞ¸Ämy.cnfÎļþ£¬Ìí¼Ó
server-id = 2
master-host = 192.168.0.1
master-user = back
master-password = back
master-port = 3306
replicate-ignore-db=mysql
replicate-do-db=test
ÖØÆôMySQL
3¡¢Æô¶¯Í¬²½
ÔÚÖ÷·þÎñÆ÷A MySQLÃüÁî·ûÏ£º
show master status;
ÏÔʾ£¨µ±È»Õâ¸öÊÇÎÒ»úÆ÷µÄÇé¿ö£¬ÄãµÄ²»¿ÉÄܸúÎÒÒ»Ñù¹þ£¬Ö»ÊǸöÀý×Ó£©£º
+------------------+----------+-------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+-------------------+------------------+
| updatelog.000028 | 313361 | test | mysql |
+------------------+----------+-------------------+------------------+
ÔÚ´Ó·þÎñÆ÷A MySQLÃüÁî·ûÏ£º
slave stop£»
CHANGE MASTER TO MASTER_LOG_FILE='updatelog.000028',MASTER_LOG_POS=313361;
slave start;
ÓÃshow slave status\G;¿´Ò»Ï´ӷþÎñÆ÷µÄͬ²½Çé¿ö
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Èç¹û¶¼ÊÇyes£¬ÄÇ´ú±íÒѾÔÚͬ²½
Íù±íÀïÃæдµãÊý¾Ý²âÊÔһϿ´ÊÇ·ñͬ²½³É¹¦£¬Èç¹û²»³É¹¦£¬¾ø¶Ô²»ÊÇÄãµÄRPÎÊÌ⣬ÔÙ¼ì²éһϲÙ×
Ïà¹ØÎĵµ£º
ÔÚmysqlÊÖ²áÀïÃæÓÐÒ»¶ÎÃèÊö¹ØÓÚlock tablesµÄÓï·¨µÄ.
LOCK TABLES tbl_name [AS alias] {READ [LOCAL] | [LOW_PRIORITY] WRITE} [, tbl_name [AS alias] {READ [LOCAL] | [LOW_PRIORITY] WRITE}] ...UNLOCK TABLESREAD
µ±±í²»´æÔÚ WRITE дËøʱ READ ¶ÁËø±»Ö´ÐÐ,Õâ¸Ã״̬ÏÂ,µ±Ç°Ïß³Ì ......
ÈçºÎͨ¹ýPHP½«excelµÄÊý¾Ýµ¼ÈëMySQLÖÐ
ÔÚ¿ª·¢PHP³ÌÐòʱ£¬ºÜ¶àʱºòÎÒÃÇ»áÓн«Êý¾ÝÅúÁ¿µ¼ÈëÊý¾Ý¿âµÄÐèÇó£¬ÈçѧÉúÐÅÏ¢ÅúÁ¿Ìí¼Óµ½Êý¾Ý¿âÖУ¬¶øÊÂÏÈÓÃexcel±àÅźã¬¶ÔexcelʵÐвÙ×÷£¬±ãÊÇÎÒÃDZȽϳ£ÓõÄÑ¡Ôñ·½Ê½¡£
ÔÚ¶ÔexcelµÄ²Ù×÷ÖУ¬phpExcelReade±ãÊǺܶàÈ˵Ĺ²Í¬ ......
ÐèÇó1£ºÔÚÒ»¸öselect ²éѯ¼¯ÖÐÔٴβéѯ
SELECT * from (SELECT field from table) AS alias
ÐèҪעÒâºóÃæµÄalias£¬ÔÚmysqlÖУ¬ÕâÊDZØÐëµÄ
ÐèÇó2£ºÒ»¸ö²éѯ¼¯µÄ½á¹û²»ÔÚÁíÒ»¸ö²éѯ¼¯ÖÐ
SELECT feild1 from table1 WHERE feild1 NOT IN (SELECT field2 from table2)
ÐèҪעÒ⣬ӦÓÃIN/NOT IN×Ó¾äʱ£¬±ØÐëÖ¸¶¨²éѯ×Ö¶ÎÃû£ ......
¡¶oracle,db2,mysqlÀà±È¡·×÷ΪÈýÖÖÊý¾Ý¿âÒ»¸öÀà±È£¬Ä¿µÄÔÚÓÚͨ¹ýÀà±È£¬Á˽âÏÖÔÚÊý¾Ý¿âÏàËƵãÓëÒìͬµã£¬Í¬Ê±¿ÉÒÔ°ïÖú´ó¼ÒÔÚÁ˽âÒ»ÖÖÊý¾Ý¿â£¬Äܹ»Ñ¸ËÙµØѧ»áÆäËûÊý¾Ý¿â¡£³õ²½¶¨ÒåΪoracle,db2,mysqlÈýÖÖÊý¾Ý¿â£¬ÒÔºó¿ÉÄÜ»¹ÊÇ×·¼Óinformix,sysbase,sql serverµÈÊý¾Ý¿â¡£
±¾Æª×÷ΪÊ×ƪ£¬Ä¿µÄÊÇÈôó¼Ò¶ÔÕâÈýÖÖÊý¾Ý¿â³£ÓõÄÖªÊ ......
µÚÒ»ÖÖ·½·¨£º
rootÓû§µÇ¼ϵͳ
usr/local/mysql/bin/mysqladmin -u root -p password ÐÂÃÜÂë
enter password ¾ÉÃÜÂë
µÚ¶þÖÖ·½·¨£º
rootÓû§µÇ¼mysqlÊý¾Ý¿â
mysql> update mysql.user set password=password("ÐÂÃÜÂë")where User="root";
mysql> flush privileges;
mysql> quit ;
mysqlÍü¼ÇrootÃÜÂëÈçºÎ ......