• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

MySQL on linux - export/import best practice

I am new to MySQL CLI and working with a database running on a Linux system.  I would like to export one of the tables in a database so I can view and update on another server.  Once I have updated the fields that need updating I will need to import this table back to its original location.  can someone provide me with some sample syntax to do this?  
1 Solution
- table to export on database server dbsvr1 (server name) - table1 on database "db1"
- database server to import, dbsvr2

Export (using mysqldump)
Command on dbsvr1
mysqldump -u root -p <db root password> db1 table1 > db1_table1.sql

Import (using mysql)
Command on dbsvr2
mysql -u root -p <dbsvr2 db root password>  < db1_table1.sql

Once you update on dbsvr2, then you can export out from dbsvr2 and import back to dbsvr1

On dbsvr2
mysqldump -u root -p <dbsvr2 db root password> db1 table1 > db1_table1_new.sql

On dbsvr1
mysql -u root -p <dbsvr1 db root password>  < db1_table1_new.sql

If you don't feel comfortable with the command line interface, you can use MySQL Workbench on a Windows machine and connect to those servers remotely for executing the import/export function.
Other graphical database tools, such as NaviCat, can do the job for you as well.
raysonlee is right...

another one you can use is:

EMS SQL Manager for MySQL

a very nice tool to have.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now