Sunday, July 15, 2007

Copying tables between mysql databases

I found a quick way to copy tables between mysql databases:

mysqldump -u(username) -p(password) (source database name) (table names...) (pipe) mysql -u(username) -p(password) (destination database name)

I used to dump tables to a file and then "source" the file into the new database. This new process goes a lot faster.

1 comment:

Cory said...

Nice one! This simple trick works great. ..and for any other users arriving here, note you can copy the DB to another server with the -h host flag.

.... (pipe) mysql -h(otherserver) -u(username) -p(password) (destination database name)