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
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com





print: 
Recent comments
16 hours 22 min ago
17 hours 50 min ago
21 hours 25 min ago
1 day 18 min ago
1 day 3 hours ago
1 day 3 hours ago
1 day 4 hours ago
1 day 5 hours ago
1 day 6 hours ago
1 day 6 hours ago