Copy one mysql database to another
Thursday, January 24th, 2008mysqladmin create [new database]
mysqldump ——opt [source database] | mysql [new database]
From the MySQL docs:
The easiest (although not the fastest) way to move a database between
two machines is to run the following commands on the machine on which
the database is located:
shell> mysqladmin -h ‘other hostname’ create db_name
shell> mysqldump ——opt db_name \
| mysql -h ‘other hostname’ db_name
Also from the MySQL docs:
–opt Same as –quick –add-drop-table –add-locks –extended-insert
–lock-tables. Should give you the fastest possible dump for reading
into a MySQL server.
Also check out mysqlhotcopy if you want to just backup the MySQL datafiles.
Also:
Export:
mysqldump –add-drop-table -u sadmin -p pass21 Customers > custback.sql
Import
mysql -u username -p -h localhost data-base-name < data.sql