To answer your question about how MySQL replicates all databases, here is how it works...
- Master has Binary Logging enabled
- Master records completed SQL Statements
- Master will inject 'USE dbname;' among the SQL Statements it records
- Slave connects to Master (IO Thread)
- Slave IO Thread requests next SQL statement from the Binary Logs
- Slave IO Thread copies it to its Relay Logs
- Slave SQL Thread Processes its Relay Log Entries FIFO (Queue)
Once USE dbname; is issued out of the relay logs, multiple SQL statements will be processes chronologically until another USE dbname; (a different database) is issued from the Relay Logs.
To see this, pick any Binary Log (except the Current One) on the Master, and run this:
mysqlbinlog binarylogname > SQLStatements.sql
To see all the binary logs and the current binary log on the Master, run these:
SHOW BINARY LOGS;
SHOW MASTER STATUS;
Long story short: By default, all DBs are replicated due to the USE dbname; command within the binary logs on the master and the relay logs on the slave.
Abdul's answer shows how to filter in or filter out databases from being processed by the slave.