Copying MySQL Database to another machine

匿名 (未验证) 提交于 2019-12-03 02:36:02

问题:

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?

回答1:

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



回答2:

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


回答3:

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



回答4:

  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



回答5:

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=... 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!