Bird
Raised Fist0
MySQLquery~10 mins

Replication basics in MySQL - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to show the command that starts the slave replication process.

MySQL
START [1];
Drag options to blanks, or click blank then click option'
ASLAVE
BREPLICA
CMASTER
DSERVER
Attempts:
3 left
💡 Hint
Common Mistakes
Using START MASTER instead of START SLAVE.
Using START REPLICA which is not valid in MySQL 5.x.
Forgetting the semicolon at the end.
2fill in blank
medium

Complete the code to check the status of the slave replication.

MySQL
SHOW [1] STATUS\G
Drag options to blanks, or click blank then click option'
ASLAVE
BSERVER
CMASTER
DREPLICA
Attempts:
3 left
💡 Hint
Common Mistakes
Using SHOW MASTER STATUS instead, which shows master info.
Using SHOW REPLICA STATUS which is not valid in MySQL 5.x.
Forgetting the \G to format output vertically.
3fill in blank
hard

Fix the error in the command to configure the slave to connect to the master.

MySQL
CHANGE MASTER TO MASTER_HOST='192.168.1.100', MASTER_USER='replica', MASTER_PASSWORD=[1];
Drag options to blanks, or click blank then click option'
Apassword123
B'password123'
C'replica'
Dreplica
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the password string.
Using the username instead of the password.
Using double quotes which may cause errors in some MySQL versions.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each database name to its size in MB from a list of tuples.

MySQL
{ [1]: [2] for [1], [2] in db_sizes }
Drag options to blanks, or click blank then click option'
Adb
Bsize_mb
Cdatabase
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for key and value.
Using variable names not matching the tuple unpacking.
Confusing key and value positions.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase database names to their sizes only if size is greater than 100.

MySQL
{ [1]: [2] for [3], [2] in db_sizes if [2] > 100 }
Drag options to blanks, or click blank then click option'
Adatabase.upper()
Bsize
Cdb
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Not converting database names to uppercase.
Using wrong variable names in the comprehension.
Missing the condition to filter sizes.

Practice

(1/5)
1. What is the main purpose of MySQL replication?
easy
A. To copy data automatically from one database server to another
B. To create backups manually on the same server
C. To speed up SQL query execution on a single server
D. To encrypt data during transmission

Solution

  1. Step 1: Understand replication concept

    Replication means copying data from one database (called master) to another (called slave) automatically.
  2. Step 2: Identify the main purpose

    The main goal is to keep data synchronized between servers without manual copying.
  3. Final Answer:

    To copy data automatically from one database server to another -> Option A
  4. Quick Check:

    Replication = automatic data copy [OK]
Hint: Replication means automatic data copying between servers [OK]
Common Mistakes:
  • Confusing replication with backup
  • Thinking replication speeds up queries on one server
  • Assuming replication encrypts data
2. Which command is used to start replication on a MySQL slave server?
easy
A. START SLAVE
B. START REPLICATION
C. BEGIN SLAVE
D. RUN SLAVE

Solution

  1. Step 1: Recall replication start command

    In MySQL, the command to start the slave replication process is START SLAVE.
  2. Step 2: Check other options

    Other options like START REPLICATION, BEGIN SLAVE, or RUN SLAVE are not valid MySQL commands.
  3. Final Answer:

    START SLAVE -> Option A
  4. Quick Check:

    Start replication = START SLAVE [OK]
Hint: Use START SLAVE to begin replication on slave server [OK]
Common Mistakes:
  • Using incorrect commands like START REPLICATION
  • Confusing with transaction commands
  • Forgetting to start the slave after setup
3. Given the command CHANGE MASTER TO MASTER_HOST='192.168.1.10', MASTER_USER='replica', MASTER_PASSWORD='pass'; executed on a slave, what does it do?
medium
A. Deletes the current master configuration
B. Starts replication immediately with given credentials
C. Creates a new master server at 192.168.1.10
D. Sets the slave to connect to the master at IP 192.168.1.10 using user replica

Solution

  1. Step 1: Understand CHANGE MASTER TO command

    This command configures the slave server to connect to a master server with specified host and user credentials.
  2. Step 2: Analyze given parameters

    It sets the master host IP to 192.168.1.10 and uses the user 'replica' with password 'pass' for connection.
  3. Final Answer:

    Sets the slave to connect to the master at IP 192.168.1.10 using user replica -> Option D
  4. Quick Check:

    CHANGE MASTER TO = configure slave connection [OK]
Hint: CHANGE MASTER TO sets slave's master connection info [OK]
Common Mistakes:
  • Thinking it starts replication immediately
  • Assuming it creates a new master server
  • Believing it deletes master config
4. You run START SLAVE; but replication does not start. Which of these is a likely cause?
medium
A. The master server is down
B. The slave user password is empty
C. The slave has not been configured with CHANGE MASTER TO
D. The slave server is running MySQL version 8

Solution

  1. Step 1: Check slave configuration

    If the slave is not configured with CHANGE MASTER TO, it does not know which master to connect to.
  2. Step 2: Understand replication start requirements

    Without proper master info, START SLAVE cannot initiate replication, even if master is up or password is set.
  3. Final Answer:

    The slave has not been configured with CHANGE MASTER TO -> Option C
  4. Quick Check:

    Missing CHANGE MASTER TO blocks replication start [OK]
Hint: Configure slave with CHANGE MASTER TO before START SLAVE [OK]
Common Mistakes:
  • Assuming START SLAVE works without configuration
  • Blaming MySQL version without checking config
  • Ignoring master server status
5. You want to set up a slave that replicates only the database named sales. Which command helps you filter replication to this database?
hard
A. CHANGE MASTER TO MASTER_DB='sales';
B. CHANGE REPLICATION FILTER REPLICATE_DO_DB = ('sales');
C. SET REPLICATION FILTER TO 'sales';
D. CHANGE REPLICATION FILTER REPLICATE_DO_DB = 'sales';

Solution

  1. Step 1: Understand replication filtering

    MySQL uses replication filters like REPLICATE_DO_DB to replicate only specific databases.
  2. Step 2: Identify correct syntax

    The correct syntax uses CHANGE REPLICATION FILTER REPLICATE_DO_DB = ('sales'); with parentheses around the database name.
  3. Final Answer:

    CHANGE REPLICATION FILTER REPLICATE_DO_DB = ('sales'); -> Option B
  4. Quick Check:

    Use REPLICATE_DO_DB with parentheses for filtering [OK]
Hint: Use CHANGE REPLICATION FILTER with REPLICATE_DO_DB and parentheses [OK]
Common Mistakes:
  • Using non-existent commands like SET REPLICATION FILTER
  • Omitting parentheses around database name
  • Trying to filter with CHANGE MASTER TO
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard