binlogdodb newdatabase After you make all of the changes go ahead and save and

Binlogdodb newdatabase after you make all of the

This preview shows page 3 - 6 out of 16 pages.

binlog_do_db = newdatabase After you make all of the changes, go ahead and save and exit out of the configuration file. Refresh MySQL. sudo service mysql restart The next steps will take place in the MySQL shell, itself. Open up the MySQL shell. mysql -u root -p We need to grant privileges to the slave. You can use this line to name your slave and set up their password. The command should be in this format: GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'password'; Follow up with: FLUSH PRIVILEGES; The next part is a bit finicky. To accomplish the task you will need to open a new window or tab in addition to the one that you are already using a few steps down SCROLL TO TOP × Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. Enter your email address Sign Up
Image of page 3
9/25/2019 How To Set Up Master Slave Replication in MySQL | DigitalOcean 4/16 the line. In your current tab switch to “newdatabase”. USE newdatabase; Following that, lock the database to prevent any new changes: FLUSH TABLES WITH READ LOCK; Then type in: SHOW MASTER STATUS; You will see a table that should look something like this: mysql> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000001 | 107 | newdatabase | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) This is the position from which the slave database will start replicating. Record these numbers, they will come in useful later. If you make any new changes in the same window, the database will automatically unlock. For this reason, you should open the new tab or window and continue with the next steps there. Proceeding the with the database still locked, export your database using mysqldump in the new window (make sure you are typing this command in the bash shell, not in MySQL). mysqldump -u root -p --opt newdatabase > newdatabase.sql SCROLL TO TOP × Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. Enter your email address Sign Up
Image of page 4
9/25/2019 How To Set Up Master Slave Replication in MySQL | DigitalOcean 5/16 Now, returning to your your original window, unlock the databases (making them writeable again). Finish up by exiting the shell. UNLOCK TABLES; QUIT; Now you are all done with the configuration of the the master database. Step Two—Configure the Slave Database Once you have configured the master database. You can put it aside for a while, and we will now begin to configure the slave database. Log into your slave server, open up the MySQL shell and create the new database that you will be replicating from the master (then exit): CREATE DATABASE newdatabase; EXIT; Import the database that you previously exported from the master database.
Image of page 5
Image of page 6

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture