Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Today I noticed a very strange issue where if I cat a SQL file and then pipe it to MySQL client, replication doesn't happen. These MySQL statements aren't also written to the binlog. But replication happens when I source the file from inside of the command line and binlogs are fine too.

To sum up, replication doesn't happen when I do:

cat file.sql | mysql -u<user> -p

Why could this be?

share|improve this question
does your file.sql has instructions like use database_name ? otherwise you will need to specify it like cat file.sql | mysql -u<user> -p database_name –  altmannmarcelo Apr 25 '13 at 9:54
All the SQL commands have the specific database on them. Eg: update database.table set database.table.column = 'somevalue' where database.table.column = 'somecondition'; –  Kailash Apr 25 '13 at 9:56
what is your result for the follow sql's on slave ? SHOW variables like 'replicate-do-db'; SHOW variables like 'replicate-ignore-db'; SHOW variables like 'replicate-do-table'; SHOW variables like 'replicate-ignore-table'; –  altmannmarcelo Apr 25 '13 at 10:05
All the above SQLs returned "Empty set" –  Kailash Apr 25 '13 at 10:10
when you run cat file.sql | mysql -u<user> -p does the information in that file aply on master? what is the output of cat file.sql | mysql -u<user> -p –  altmannmarcelo Apr 25 '13 at 10:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.