當我手動執行數據時,我的數據被從master數據庫複製,但是當它從PHP插入master數據庫時,它不會被複制到從數據庫。MYSQL主從複製不能用於PHP
我的主數據庫 - my.cnf中
我從數據庫 - my.cnf中
server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
relay-log = /var/log/mysql/mysql-relay-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = database
replicate_do_db = database
slave_net_timeout = 30
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1
我的數據庫表設置
`id` int(11) NOT NULL AUTO_INCREMENT,
`tmdbid` varchar(9) NOT NULL,
`poster` varchar(256) NOT NULL,
`title` varchar(128) NOT NULL,
`tagline` varchar(128) NOT NULL,
`plot` text NOT NULL,
`year` year(4) NOT NULL,
`release` varchar(18) NOT NULL,
`runtime` char(6) NOT NULL,
`genres` varchar(256) NOT NULL,
`actors` text NOT NULL,
`votes` varchar(5) NOT NULL,
`mpaa` varchar(6) NOT NULL,
`file2` text NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`link` text NOT NULL,
`file` text NOT NULL,
`link1` text,
`link2` text,
`uploaded` text,
`been_sent_to_folder` text,
`poster_backup` varchar(256) NOT NULL,
`saved_poster_name` text NOT NULL,
`poster140x100` varchar(256) NOT NULL,
`poster65x95` varchar(256) NOT NULL,
`poster_orig` varchar(256) NOT NULL,
PRIMARY KEY (`tmdbid`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
PHP插入到DB
mysql_query("INSERT INTO `database`.`tmdb` (`id`,`tmdbid`,`poster`,`title`,`tagline`,`plot`,`year`,`release`,`runtime`,`genres`,`actors`,`votes`,`mpaa`,`file2`,`link`,`file`,`poster_backup`,`saved_poster_name`,`poster140x100`,`poster65x95`,`poster_orig`) VALUES (NULL,'".$tmdbid."','".$poster."','".$title."','".$tagline."','".$plot."','".$year."','".$imrelease."','".$runtime."','".$genres."','".$actors."','".$votes."','".$mpaa."','".$file2."','".$link."','".$file."','".$poster_backup."','".$saved_poster_name."','".$finalthumb."','".$imgfinal."','".$imgfinal225."');")...
'replicate_do_db'如何? – iC0NiC
[完全相同的問題](http://dev.mysql.com/doc/refman/5.1/en/replication-options-slave.html#option_mysqld_replicate-do-db)。如上所述,無論是基於ROW還是所有數據庫。如果這是另一個數據庫的存儲大小問題,那麼可以使它們成爲'BLACKHOLE'表:該引擎不存儲任何數據,但複製將工作(即使是針對其他從屬的binlog)。 – Wrikken