

Log into the MySQL server and run the following queries: FLUSH TABLES WITH READ LOCK We need to lock the master database and get it's status. The relica database then knows where in the binary log to start reading in order to replay queries made on the master database.
#PHPMYADMIN REPLICATION TUTORIAL UPDATE#
We can then update the replicate database with the master database's "state" (aka mysqldump from master and import that dump into the replica) and tell it the binary log position. We'll get this information, export the database in this state, and then release the lock. What we're doing here is finding out exactly where MySQL is currently in writing to the binary log. Get the current "position" of where MySQL is in the bin log (where it's left off writing to the binary log).Lock the master database from accepting new queries that may change the database.Once the user is created, we need to do a few things: Restart the server ( sudo service mysql restart) once that's done and we can move onto the meat of this process. Relay-log = /var/log/mysql/mysql-relay-bin.log Configure Replica ServerĪfter logging into the replica MySQL server we'll edit the my.cnf to give it a unique ID and setup some logs:Įdit /etc/mysql/my.cnf: # Give the server a unique ID You may want to create one that can only connect from specific hosts - your replica server(s). In this case, I made a user "replication_user" who can connect from any host ( %). GRANT REPLICATION SLAVE ON *.* TO IDENTIFIED BY 'some_password' Then log into MySQL on the Master MySQL server and create the replication user - the user who will connect to the master server to copy it.

Restart the server once that's done ( sudo service mysql restart)! In this video, we're using Ubuntu, so that file is located at /etc/mysql/my.cnf: # Give it a unique server id

We'll start by configuring the Master MySQL instance.Įdit the my.cnf file. One database likely has data in it (the master database) while the replica database is a new, empty MySQL instance. To start, I'll pretend you have 2 database installed on 2 servers. I'll assume you're in scenario 2, as I think it's likely a more common scenario. If you have an in-production database, the setup to create a Master-Replica setup will force you to freeze your database temporarily.
