I am using mysql as database for my application and for the purpose of fail over and I need to sync the data from one local mysql database in system one to other local database in system 2 connected through same network.So I want to know how to connect local database in other system and sync data automatically
You need MySQL replication.
Here is the official documentation https://dev.mysql.com/doc/refman/8.0/en/replication.html
I like to use step by step guides, so here's a more simple explanation: http://www.clusterdb.com/mysql-cluster/get-mysql-replication-up-and-running-in-5-minutes
Those docs should work for MySQL 5.X and 8.X.