Dump just one MySQL table

Logan wanted a way to move one table from a MySQL database to another database on a separate server. We found this idea in a closed discussion on Stack Overflow

mysqldump -u user dbname tablename -p > tablename_dump.sql

The thing that I thought was really cool and that I didn’t know before (‘cos I didn’t read enough of the manual) was that you can put a single table name after the database name and just get the structure and data for that table. You could then use that to send the new table and its data to your new database. In fact, the guy that posted it actually put it like this…

mysqldump -u username yourpass dbname tablename -p | mysql -u user secondDB -p

…which I haven’t used, but looks like a really neat way to do it.

Original Stack Overflow thread: http://stackoverflow.com/questions/15558461/move-table-from-one-database-to-another-in-mysql

 

Advertisements

About Miller

I live in Second Life with my shoulder pet Logan. I write code for her and I sometimes greet people in the Virtual Kennel Club Dog Park at Turing Isle: http://slurl.com/secondlife/Turing Isle/128/126/27/ I also write in my own Blog at http://miller.logspark.com and sometimes even on FB.
This entry was posted in DB, Reminders and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s