MySQL - Dump Restore

Copy one DB to another DB with another name same instance:

mysqldump db | mysql new_db

Dump schema only to file:

mysqldump -d -u user -p db

Dump database to file:

mysqldump db > dump.sql

Dump all databases to file:

/usr/bin/mysqldump -u user -pxxx --all-databases -r /var/backups/dumpall.sql

Dump nicely backup database without causing lock:

nice -n 10 ionice -c2 -n 7 mysqldump --all-databases -u user -pxxx--single-transaction --quick --lock-tables=false 2>/dev/null | nice bzip2 -c >/var/backups/dumpall.mysql.bz2

Restore DB from file:

mysql -u user -pxxx db < dump.sql