If you need to copy DB, lets say from production to develop you can use this script and call it like "develclone.sh original_db cloned_db"
For faster cloning it will exclude cache tables data.
#!/bin/sh
SRC_DB="$1"
if [ -z "$SRC_DB" ]; then
echo "Missing source database as first argument."
echo "$0 SRC_DB DST_DB"
exit 1
fi
DST_DB="$2"
if [ -z "$DST_DB" ]; then
echo "Missing destination database as first argument."
echo "$0 SRC_DB DST_DB"
exit 1
fi
if [ "x$SRC_DB" = "x$DST_DB" ]; then
echo "Source and destination cannot be the same."
exit 1
fi
echo "Building table ignore list..."
for TABLE in $(mysql -Bsce "use $SRC_DB; show tables;" | grep "^cache_"); do
IGNORED_TABLES="$IGNORED_TABLES --ignore-table=$SRC_DB.$TABLE"
done
echo "Done."
echo "Building table definition only list..."
for TABLE in $(mysql -Bsce "use $SRC_DB; show tables;" | grep "^cache_"); do
DEFINITION_TABLES="$DEFINITION_TABLES $TABLE"
done
echo "Done."
FILENAME=$(mktemp /tmp/$SRC_DB.XXXXX.gz)
echo "Dumping database $SRC_DB to $FILENAME file..."
(mysqldump --set-gtid-purged=OFF --add-drop-table --single-transaction --quick "$SRC_DB" $IGNORED_TABLES; mysqldump --set-gtid-purged=OFF --add-drop-table --single-transaction --quick --no-data "$SRC_DB" $DEFINITION_TABLES) | mbuffer | pigz -c > "$FILENAME"
echo "Done."
echo "Restoring $FILENAME file into DB $DST_DB database..."
pigz -dc "$FILENAME" | mbuffer | mysql "$DST_DB"
echo "Done."
rm -f "$FILENAME"
exit 0