• +91 9723535972
  • info@interviewmaterial.com

My SQL Interview Questions and Answers

Question - how to set up complete replication on your current MySQL server?

Answer - Below is a quick description of how to set up complete replication on your current MySQL server. It assumes you want to replicate all your databases and have not configured replication before. You will need to shutdown your master server briefly to complete the steops outlined below. Make sure you have a recent version of MySQL installed on the master and slave(s). Use Version 3.23.29 or higher. Previous releases used a different binary log format and had bugs which have been fixed in newer releases. Please, do not report bugs until you have verified that the problem is present in the latest release. Set up special a replication user on the master with the FILE privilege and permission to connect from all the slaves. If the user is only doing replication (which is recommended), you don't need to grant any additional privileges. For example, to create a user named repl which can access your master from any host, you might use this command: GRANT FILE ON *.* TO repl@"%" IDENTIFIED BY ''; Shut down MySQL on the master. mysqladmin -u root -p shutdown Snapshot all the data on your master server. The easiest way to do this (on Unix) is to simply use tar to produce an archvie of your entrie data directory. The exact data directory location depends on your installation. tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir Windows users can use WinZip or similar software to create an archive of the data directory. In my.cnf on the master add log-bin and server-id=unique number to the [mysqld] section and restart it. It is very important that the id of the slave is different from the id of the master. Think of server-id as something similar to the IP address - it uniquely identifies the server instance in the comminity of replication partners. [mysqld] log-bin server-id=1 Restart MySQL on the master. Add the following to my.cnf on the slave(s): master-host= master-user= master-password= master-port= server-id= replacing the values in <> with what is re

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners