I'm trying to implement master slave replication and It's works fine with no errors, database is replicated on slave, but when I close my servers and open them again and add something in masters database it's not replicated in slave , do I have to follow these steps every time I start my server?
Setup on Masters server
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl_user'@'192.168.1.20'
IDENTIFIED BY 'secretpassword';
mysql> FLUSH PRIVILEGES;
mysql> use mydb;
mysql> FLUSH TABLES WITH READ LOCK;
mysql> exit;
my.cnf file
[mysqld]
log-bin=mysql-bin
binlog-do-db=mydb
server-id=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
in terminal again
# service mysqld restart
mysql > SHOW MASTER STATUS;
# mysqldump -u root -p mydb > mydb.sql
# scp mydb.sql 192.168.1.20:/opt/
SETUP SLAVE 2 SERVER
# vim /etc/my.cnf
[mysqld]
server-id=2
replicate-do-db=mydb
# /etc/init.d/mysqld restart
# mysql -u root -p mydb < mydb.sql
mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.10',
-> MASTER_USER='repl_user',
-> MASTER_PASSWORD='secretpassword',
-> MASTER_LOG_FILE='mysql-bin.000002',
-> MASTER_LOG_POS=107;
mysql> SLAVE START;
mysql> show slave status \G
Also it's is only replicating one database by dumping one database on slave server
# mysqldump -u root -p mydb > mydb.sql
How can I dump all the databases from masters to slave server?