Contoh Script Restore Database dari Table per Table MySQL

Kadang ya kita perlu restore database mysql tabel per tabel sql file, maka berikut ini adalah contoh scriptnya

file_nama_table=/table.txt

while read nama_table; do
	if [ ! -z "/root/db/$nama_table.sql" ]; then
		tfile="/root/db/${nama_table}.sql"
		echo $tfile
		mysql -u user_mysql --password="paswwd-mysql" nama_db <  $tfile
	fi
done<$file_nama_table

isi dari table.txt adalah

nama-table1.sql
nama-table2.sql
nama-table3.sql

dst…