There are several solutions to fix this problem, but not automatically!
But @ first the error message would be helpfull to understand the cause.
Typically the slave tries to reconnect to the master and continues replication by itself. So the question it, what is the current problem?
Manually solutions:
Solution #1 Skip Error
Dataloss may happen!
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
start slave;
show slave status \G;
Repeat it as long, the slave is up an running.
But be aware, data may be lost.
Solution #2 SQL Dump / Backup Restore.
On Master:
Do an Database Lock first.
show master status \g;
Result may look like:
show master status \g;
+------------------+-----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+-----------+--------------+------------------+-------------------+
| mysql-bin.000063 | 176085122 | | | |
+------------------+-----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
Do an SQL Dump on Master an all databases.
Restore the SQL Dump on the slave server.
Maybe remove master.info or edit it with new File and Logposition of Master.
Release DB Lock on Master.
Start Slave, replikation should run again.
Solution #3
Master and Slave Datebase must be the same version, same hardware architecture and operating system.
Instead of mysql dump you could stop the database on master and slave.
Just copy or sync the database files from master to slave.
auto.conf contains a unique server id. Remove this file or edit the id on the slave system, before starting the slave server.
Furter information for "change_master_to" https://mariadb.com/kb/en/library/change-master-to/
Hopefully you know the basics to set up an master / slave replication.
However, this steps can be done by a script and initiated by crontab (@reboot). But i would never do it automatically, only i don't care about the data and theire consistency.