First, run the following script. Second, execute provided commands.

mysql --database=db_name -u db_username -p -B -N -e "SHOW TABLES"  | awk '{print "ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"}'