Please help us improve HowtoForge and take our survey:
How To Set Up Database Replication In MySQL - Page 2
|
2 Configure The Slave On the slave we first have to create the database exampledb: mysql -u root -p If you have made an SQL dump of exampledb on the master and have transferred it to the slave, then it is time now to import the SQL dump into our newly created exampledb on the slave: mysql -u root -p<password> exampledb < /path/to/exampledb.sql (Replace <password> with the real password for the MySQL user root! Important: There is no space between -p and <password>!) If you want to go the LOAD DATA FROM MASTER; way then there is nothing you must do right now. Now we have to tell MySQL on the slave that it is the slave, that the master is 192.168.0.100, and that the master database to watch is exampledb. Therefore we add the following lines to /etc/mysql/my.cnf:
Then we restart MySQL: /etc/init.d/mysql restart If you have not imported the master exampledb with the help of an SQL dump, but want to go the LOAD DATA FROM MASTER; way, then it is time for you now to get the data from the master exampledb: mysql -u root -p If you have phpMyAdmin installed on the slave you can now check if all tables/data from the master exampledb is also available on the slave exampledb. Finally, we must do this: mysql -u root -p In the next command (still on the MySQL shell) you have to replace the values appropriately: CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slave_user', MASTER_PASSWORD='<some_password>', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;
Now all that is left to do is start the slave. Still on the MySQL shell we run START SLAVE; That's it! Now whenever exampledb is updated on the master, all changes will be replicated to exampledb on the slave. Test it!
Links
|




print: 


Recent comments
21 hours 10 min ago
2 days 5 hours ago
3 days 4 hours ago
4 days 13 hours ago
4 days 23 hours ago
5 days 9 hours ago
6 days 19 hours ago
1 week 3 days ago
1 week 3 days ago
1 week 4 days ago