MySQL 主从同步错误(error)解决


1出现错误(error)提示

 

Slave I/O: error connecting to master 'backup@192.168.1.x:3306' - retry-time: 60  retries: 86400, Error_code: 1045

解决方法(fāng fǎ)

从服务器上删除掉所有二进制日志文件包括一个数据(data)目录下master.info文件和hostname-relay-bin开头文件

master.info:记录(record)了Mysql主服务器上日志文件和记录(record)位置连接密码(code) 

 2出现错误(error)提示

 

Error reading packet from server: File '/home/mysql/mysqlLog/log.000001' not found (Errcode: 2) ( server_errno=29)

解决方案:

由于主服务器运行了一段时间产生了二进制文件而slave是从log.000001开始读取删除主机二进制文件包括log.index文件

3错误(error)提示如下

 

Slave SQLError 'Table 'xxxx' doesn't exist' on query. Default database: 't591'. Query: 'INSERT INTO `xxxx`(type,post_id,browsenum) SELECT type,post_id,browsenum FROM xxxx WHERE hitdate='20090209'', Error_code: 1146

解决方法(fāng fǎ)

由于slave没有此table表添加这个表使用slave start 就可以继续同步

 

4错误(error)提示如下

 

Error 'Duplicate entry '1' for key 1' on query. Default database: 'movivi1'. Query: 'INSERT INTO `v1vid0_user_samename` VALUES(null,1,'123','11','4545','123')'

 

 

Error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ' at line 1' on query. Default database: 'club'. Query: 'INSERT INTO club.point_process ( GIVEID, GETID, POINT, CREATETIME, DEMO ) VALUES ( 0, 4971112, 5, '2010-12-19 16:29:28', '

1 row in set (0.00 sec)

 Mysql > Slave statusG;

显示:Slave_SQL_Running 为 NO

解决方法(fāng fǎ):

Mysql > stop slave;

Mysql > set global sql_slave_skip_counter =1 ;

Mysql > start slave;

5错误(error)提示如下

# show slave statusG;

 

Master_Log_File: mysql-bin.000029

Read_Master_Log_Pos: 3154083

Relay_Log_File: c7-relay-bin.000178

Relay_Log_Pos: 633

Relay_Master_Log_File: mysql-bin.000025

Slave_IO_Running: Yes

Slave_SQL_Running: No

Replicate_Do_DB: club

Replicate_Ignore_DB: 

Replicate_Do_Table: 

Replicate_Ignore_Table: 

Replicate_Wild_Do_Table: 

Replicate_Wild_Ignore_Table: 

Last_Errno: 1594

Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.

Skip_Counter: 0

Exec_Master_Log_Pos: 1010663436

这个问题(problem)原因是主数据(data)库突然停止或问题(problem)终止更改了mysql-bin.xxx日志slave服务器找不到这个文件需要找到同步点和日志文件然后chage master即可

解决方法(fāng fǎ):

 

 change master to 

 master_host='211.103.156.198',

 master_user='同步帐号', 

 master_password='同步密码(code)', 

 master_port=3306, 

 master_log_file='mysql-bin.000025', 

 master_log_pos=1010663436;

6错误(error)提示如下

 

Error 'Unknown column 'qdir' in 'field list'' on query. Default database: 'club'. Query: 'insert into club.question_del (id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,banzhu_uid,banzhu_uname,del_cause,qdir) select id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,'1521859','admin0523','无意义回复',qdir from club.question where id=7330212'

1 row in set (0.00 sec)

这个错误(error)就说club.question_del 表里面没有qdir这个字段 造成加上就可以了~

在主mysql : 里面查询 Desc club.question_del; 

 错误(error)从服务器上执行 : alter table question_del add qdir varchar(30) not null;

相关内容