Sumon Sarker Sumon Sarker - 1 month ago 9
Linux Question

How can I insert MySQL remote database table into local database table?

Remote Server Database (IP: 192.168.1.19)


Database Name :
RemoteDB


Table Name        :
RemoteTable



Local Server Database (IP: 192.168.1.35)


Database Name :
LocalDB


Table Name        :
LocalTable



MySQL Query

INSERT INTO LocalDB.LocalTable SELECT * FROM RemoteDB.RemoteTable


But, This query is not executing, Because of different database connection.

How can I execute this query from local server (IP: 192.168.1.35)? Or any linux shell command?

Answer
mysqldump -uRemoteusername -pRemotepassword -h192.168.1.19 RemoteDB RemoteTable  --set-gtid-purged=OFF  | mysql -h192.168.1.35 -uLocalname -pLocalpassword   LocalDB
Comments