charlieanstey
2/13/2015 - 6:10 PM

MySQL :: mysqldump commands, transfer

MySQL :: mysqldump commands, transfer


# Shell scripts

# Dump database and unzip
mysqldump db_name -u user_name -p | gzip > db_uname.sql.gz

# Unzip and import database
gunzip < db_name.sql.gz | mysql db_name -u user_name -p

# Transfer database (on source server)
mysqldump db_name -u user_name -p | mysql -h 'hostname' db_name -u user_name -p

# Transfer database (on destination server)
mysqldump -h 'hostname' db_name -u user_name -p | mysql db_name -u user_name -p