//Tips tagged mysql
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
The following command will allow you to copy a table from the MySQL database on a remote host, to a different MySQL database on your local host.

mysqldump -h [remote IP] -u[user] -p[pass] from_db from_table | mysql -u[user] -p[pass] target_db

The first username and password are for the remote database and the last ones are for your local database.

View Comments »

Tip 669 gave a command to copy a table between remote MySQL databases, but how about if you want to copy the whole DB to a new host?

The following command will copy the database 'old_db' from the local host to 'new_db' on the specified remote host.

mysqldump --add-drop-table --extended-insert --force --log-error=err.log -u[user] \
-p[pass] old_db | ssh -C user@host "mysql -u[user] -p[pass] new_db"

View Comments »

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit