Artem Moskalev
Artem Moskalev

Reputation: 5818

Copying MySQL Database to another machine

I have a MySQL Database on mt Windows computer. I need to take one database and copy it to another machine. The other machine also runs windows and has MySQL Database. The two machines cannot be connected through internet. What shall I do? How can that be done through USB-card?

Upvotes: 3

Views: 15879

Answers (5)

thar45
thar45

Reputation: 3560

Make a export DB Mysqldump in a sql file and copy the sql file to USB card and import it into the other machine.Follow the steps it would help you to achieve it

To make mysql dump for reference see here Sample:

mysqldump -u admin -p passwd DB_Name > file/path/filename.sql

import the sql file to the mysql DB as

sample :

  mysql > use DB_Name;
  mysql >source yourfile.sql

(or)

  mysql -u USERNAME -p PASSWORD DATABASE-NAME < file/path/filename.sql

Correct me if 'm wrong

Upvotes: 7

tadman
tadman

Reputation: 211560

The MySQL Workbench package has a backup and restore procedure built in to it. The database backup is really just a long SQL file that can be re-played into another database in order to replicate your original data. It can even schedule backups.

There is also the command-line tool mysqldump that does the same thing but is not as easy to use. If you're doing this frequently you'll want to script it so you don't need to remember the specific command-line options:

 mysqldump --single-transaction --quick --user=... --password=... database | gzip -9 > backup.sql.gz
 gunzip -dc backup.sql.gz | mysql --user=... --password=... 

Upvotes: 1

triclosan
triclosan

Reputation: 5714

The best way it dump your DB as SQL file. And then import on another machine.

mysqldump -uuser -i uutfile.sql -p db_name 
mysql -uuser -p < uutfile.sql

Upvotes: 2

Udan
Udan

Reputation: 5599

  1. Export the data with:

    mysqldump db_name > backup-file.sql

  2. Use the stick

  3. Import the data with:

    mysql -u username -p database < backup-file.sql

Upvotes: 1

Sashi Kant
Sashi Kant

Reputation: 13465

Take the backup (sql dump) of the current database, and execute the backup in the other machine.

Upvotes: 1

Related Questions