WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

MySQL · Advanced · question 43 of 100

What are the different types of replication in MySQL, and how do they work?

📕 Buy this interview preparation book: 100 MySQL questions & answers — PDF + EPUB for $5

MySQL Replication is the process of copying data from one database to another in a master-slave architecture. It is a powerful feature that allows data to be distributed across multiple MySQL servers for high availability or load balancing. There are different types of MySQL Replication, which are:

1. Statement-based replication (SBR): Statement-based replication (SBR) is the default replication mode in MySQL. In SBR, the SQL statements executed on the master server are stored in the binary log, which is then used to replay the same statements on the slave server(s) to replicate the data. SBR can be used for simple replication setups and is generally faster than row-based replication but can lead to issues with non-deterministic statements. For Example, the statement “INSERT INTO table_name (sometext) VALUES (DATE_FORMAT(NOW(),’

2. Row-based replication (RBR): Row-based replication (RBR) replicates the actual rows changed on the master server to the slave servers. In this mode, the log events for the row change are actually written to the binary log. As a result, RBR provides a more accurate duplication of the data from the master to the slave, often resulting in better data integrity. RBR is ideal for databases that use non-deterministic functions but can lead to increased network traffic and storage requirements on the slave server.

3. Mixed-based replication: Mixed-based replication is a mode in which MySQL uses both statement-based and row-based replication methods, depending on the type of SQL statement being executed. In this mode, deterministic statements, such as INSERT or UPDATE statements that do not use non-deterministic functions, are logged using the statement-based method, whereas non-deterministic statements, such as those that use the NOW () function, are logged using row-based replication.

Each of these replication types has its own benefits and drawbacks. Choosing the right replication mode depends on the specific needs of the database setup. In general, SBR is faster and requires less storage, but can have issues with non-deterministic functions. RBR provides better data integrity, but can be slower and more storage-intensive. Mixed-based replication, as the name suggests, offers the best of both worlds, but requires careful configuration to balance the benefits against the drawbacks.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic MySQL interview — then scores it.
📞 Practice MySQL — free 15 min
📕 Buy this interview preparation book: 100 MySQL questions & answers — PDF + EPUB for $5

All 100 MySQL questions · All topics